JavaScript 的开窗器关闭问题
我在使用 javascript 进行浏览器窗口管理时遇到问题。 我的概念验证应用程序中有两页。 第一页包含登录信息(用户名、密码、登录按钮等),第二页是管理屏幕。 我需要当用户按下登录屏幕上的登录按钮时,它会打开主屏幕,并且主屏幕必须打开新窗口而不是全屏。 我的意思是 Windows 操作系统的关闭、最小化、最大化按钮和底部栏必须保留在屏幕上。
在登录屏幕上打开新窗口时,它必须自动关闭。 我找到了很多示例脚本,但每个脚本都给我提供了相同的结果。
例如; 以下脚本解决了我的问题,但同样的问题仍然存在,
Firefox 不会自行关闭开启窗口, 即 6.0 关闭开启器窗口 - 它正在工作 即 7.0 - 8.0 在关闭之前它会询问“您正在查看的网页正在尝试关闭窗口”。
window.open("Content/StartPage.aspx", windowName, "menubar=0, location=0, resizable=1, status=1, width=" + screen.width + ",height=" + screen.height);
if (window.name != windowName) {
var me = window.self;
me.opener = window.self;
me.close();
}
我如何打开新窗口并关闭具有上述要求的开启器而不询问浏览器问题?
谢谢。
I have a problem with browsers window managament with javascript.
I have two page in my proof of concept application. First page contains login information (username, password, login button etc.) and second page is a managament screen. I need that when the user pressed to the login button on the login screen it open to main screen and main screen must be open new window without full screen. I mean close, minimize, maximize buttons and bottom bar of the windows os must be stayed on the screen.
During opening the new window on the login screen, it must be close itself automatically. I have found many example script but every script giving same results to me.
For example; following script solving my problem but same problems continue for me,
firefox does't close opener window it self,
ie 6.0 closing opener window - it's working
ie 7.0 - 8.0 before the close it self it asking "The webpage you are viewing is trying to close the window".
window.open("Content/StartPage.aspx", windowName, "menubar=0, location=0, resizable=1, status=1, width=" + screen.width + ",height=" + screen.height);
if (window.name != windowName) {
var me = window.self;
me.opener = window.self;
me.close();
}
How can i open new window and close the opener with above requirements without ask browsers question ?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能根据浏览器的安全保证来做到这一点,有些操作不允许在没有用户干预的情况下直接通过javascript进行管理。
You cannot do it according the security assurance of browser, there are some action which doesn't allow to be managed directly via javascript without user interference.
在你的新窗口中,在 body onload 上尝试类似的操作:
尽管如此,这个解决方案并不完美,我只能让它在 Internet Explorer 中工作,即使如此,我还是收到了关闭父窗口的警告弹出窗口。 这可能是一个无法切实解决的问题。
Try something like this in your new window, on the body onload:
Still, this solution isn't perfect, I only got it to work in Internet Explorer, and even then, I got a warning popup for closing the parent window. This might be something that can't feasibly be solved.