window.open被ie阻止的解决办法 - TOMMYHU - 专注互联网开发及运营技术,提供相关资料及软件下载,奇趣网络时事评论!
Mar 9

window.open被ie阻止的解决办法 不指定

在web编程过程中,经常会遇到一些页面需要弹出窗口,但是在服务器端用window.open弹出的窗口会被IE阻止掉,showModalDialog弹出的窗口有时并不能满足我们需要,我们需要弹出新的浏览器窗口。
window.open被ie阻止的解决办法 window.open window.open被阻止 弹出窗口被阻止 ie阻止弹出窗口
为什么我们编写的弹出窗口会被IE阻止呢,原来IE会自动判断弹出窗口的状态,它会阻止自动弹出的窗口,而通过我们用鼠标点击弹出的窗口,它是不会阻止的。这里就有一个问题,有人说:我的程序是写在服务器按钮里的,也是通过鼠标点击弹出的呀!其实只有在加载页面后,我们点击到弹出这段时间页面没有被重新加载的情况下,弹出的窗口才不会被阻止!这也就是说,写在服务器控件的回传事件里的window.open都会被阻止。

最简单有效的方法如下:
在window.open()函数中增加一个参数,将target设置为‘self’,
即改为使用: window.open(link,'_self');

微软的网站上的说明:

Pop-Up Blocking
The Pop-up Blocking feature blocks pop-up (and pop-under) windows initiated automatically by a Web site. Internet Explorer blocks Pop-up windows in the Internet and Restricted sites zones by default. However, the Pop-up Blocker enables pop-up windows initiated by a user action. Users can configure Internet Explorer 6 for Windows XP with SP2 to be more or less restrictive. Users can also turn off the Pop-up Blocker altogether. Generally, the Pop-up Blocker enables a window to open under the following circumstances:

? When initiated by user action, such as clicking a button or hyperlink

? When opened in the Trusted sites and Local intranet zones (considered safe)

? When opened by other applications running on the local computer


The affected script methods are:

window.open
window.showHelp
window.showModalDialog
window.showModelessDialog
window.external
window.NavigateAndFind
注:
Pop-ups created with window.createPopup are unaffected by the Pop-up Blocker.
▲返回顶部
Last modified by tommyhu on2011/03/15 22:55

互联网开发网友
2012/06/01 18:18
[haha 这思路真是服气了, 不能 blank 还用 window.open 作甚?
互联网开发网友
2012/05/23 09:15
luguoaiyaogrinchunda2da1aiyaoaiyaogringringrin
互联网开发网友 Email Homepage
2012/01/20 14:26
说得有道理,确实不错,先顶顶再说!!!!
Pages: 1/1 First page 1 Final page
Add a comment

Nickname

emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot