window.close在chrome中不起作用 [英] window.close is not working in chrome

查看:608
本文介绍了window.close在chrome中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





此代码工作正常,因为它关闭当前窗口并在新窗口中打开软件使用IE浏览器但不使用Chrome





Hi,

This code is working fine as it close the current window and open software in new window With IE but not working with Chrome


<html>
<head>
<title>Contentverse Online</title>
</head>
<script>
function closeCurrentWindow() {
            var version=0;
            if (navigator.appVersion.indexOf("MSIE")!=-1){
                        var temp=navigator.appVersion.split("MSIE");
                        version=parseFloat(temp[1]);
            }
            if (version>=5.5 && version<=6) {

                        this.focus();

                        self.opener = this;

                        self.close();

            } else {

                        window.open('','_parent','');

                        window.close();

            }

}

</script>
<body>
<script>

window.open("Sign.asp?Home=C:/Program Files/ViewWise Online&VWOFlavor=Full","myWindow",'top=0,left=0,width='+screen.width+',height='+screen.height+',status=yes,resizable=no,scrollbars=yes');
closeCurrentWindow();
</script>
</body>
</html>

推荐答案

此代码在某种程度上是滥用的。您正在通过代码打开新窗口,这相当于创建弹出窗口。这被认为是邪恶的,很多用户会阻止它。然后,您尝试在未经用户同意的情况下关闭当前窗口。如果某个网站对我这么做,我通常把它放到我的黑名单中。这很讨厌。



我建议你复习这个设计。从逻辑上讲,您的代码等同于重定向到其他URL,这就是您应该做的。您强制用户的浏览器窗口大小和其他参数,但您不知道也不使用屏幕大小。你怎么知道用户会喜欢它?在几乎所有情况下,窗口的大小应该由用户决定。



还有一个问题:没有硬编码文件路径的情况,例如因为您的C:/ Program Files / ViewWise Online非常有用。你怎么知道客户端甚至有磁盘C:这样的东西。即使在Windows上,情况并非总是如此,在其他平台上,那些愚蠢的C:和D:从未存在过。再次,这种设计是不可接受的。



怎么办?你可以得到一个建议,分享你的最终目标。



-SA
This code is abusive, to certain extent. You are opening new windows by code, which is equivalent to creation of pop-up window. This is considered as evil, and many users will block it. And then you try to close a current window, without user's consent. If some site does it to me, I usually put it to my black list. This is nasty.

I suggest you review this design. Logically, your code is equivalent to redirection to other URL, and this is what you should do. You force the user's browser window size and other parameter, but you don't know and don't use the screen size. How you know that the user would like it? The size of the window should be decided by the user, in almost all cases.

One more problem: there are no situations where a hard-coded file path, such as your "C:/Program Files/ViewWise Online" can be useful. How do you know that a client even has such thing as disk "C:". Even on Windows, this is not always the case, and on other platforms those stupid "C:" and "D:" never exist. Again, this design is unacceptable.

What to do? You can get an advice is you share your ultimate goals.

—SA


这篇关于window.close在chrome中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆