如何在vbscript或javascript中关闭Internet Explorer的当前选项卡

时间:2012-10-26 13:00:07

标签: javascript internet-explorer vbscript

我想点击“退出”按钮关闭Internet Explorer的当前标签。这是在我的Web应用程序中实现的新功能。我的应用程序仅支持Internet Explorer。 Logout按钮所在的页面是window.close()的多个页面的组合。

我在vbscript中使用了以下代码来关闭Internet Explorer的当前浏览器窗口:

 if(window.opener = Empty) then
     dim x
     x = "<%=Request.Browser.MajorVersion%>"

     if(x="6") then
        window.parent.opener = "x"
        window.parent.close
     else  
      'I need code for closing the tab here for IE7
      end if   

  end if  

我使用过“&lt;%= Request.Browser.MajorVersion%&gt;”获取Internet Explorer的版本。它是IE6然后代码工作正常,因为IE6中没有选项卡功能,但如何关闭IE7的当前选项卡。请帮助我在这种情况下,以便我也可以关闭IE7的当前选项卡。事先提醒!

2 个答案:

答案 0 :(得分:2)

您可以尝试关闭IE7中的标签: -

    window.parent.opener = "x"
    window.parent.close

我遇到了同样的问题,发现这对我来说很好。虽然这会给你一个额外的消息(微软警告信息): -

enter image description here

答案 1 :(得分:0)

现代浏览器不允许您关闭未使用window.open创建的窗口或选项卡。任何使其工作的方法都是HACK,并且在浏览器升级时必然会中断。

相关问题