最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - window.open() still returns null - Stack Overflow

programmeradmin0浏览0评论

I am using IE8 on Windows 7. Referred to several threads and understand that in IE8 when I am using window.open to popup a new window, the JavaScript window.open is returning null value.

If I run IE as administrator or disable the protected mode, I see the window.open returns the expected object.

I am looking out for a solution apart from the options mentioned above. For such a small feature (opening a popup) I cannot ask customer to run IE as administrator or disable the protected mode.

If there is any work around, please let me know. It will be a great help.

Primarily, I want to make sure that only one window is opened when user clicks multiple times on the link and give the focus to the window which is already open. To achieve this I need to get the object from window.open so that I can check if the window is already open and give the focus to the already opened window. Otherwise open a new window.

I am using IE8 on Windows 7. Referred to several threads and understand that in IE8 when I am using window.open to popup a new window, the JavaScript window.open is returning null value.

If I run IE as administrator or disable the protected mode, I see the window.open returns the expected object.

I am looking out for a solution apart from the options mentioned above. For such a small feature (opening a popup) I cannot ask customer to run IE as administrator or disable the protected mode.

If there is any work around, please let me know. It will be a great help.

Primarily, I want to make sure that only one window is opened when user clicks multiple times on the link and give the focus to the window which is already open. To achieve this I need to get the object from window.open so that I can check if the window is already open and give the focus to the already opened window. Otherwise open a new window.

Share Improve this question edited Jan 9, 2014 at 11:13 BenMorel 36.6k51 gold badges205 silver badges336 bronze badges asked Jul 5, 2012 at 7:24 user1501905user1501905 411 gold badge1 silver badge2 bronze badges 2
  • Does this help ? – The Alpha Commented Jul 5, 2012 at 7:38
  • stackoverflow./q/1827616/1341062 – Jeyan Commented Oct 28, 2013 at 5:20
Add a ment  | 

2 Answers 2

Reset to default 6

For IE10, window.open returns a NULL reference object if Enable Protected Mode is checked under Internet Options->Security->Security Level for this zone and the ZONE is different i.e. in my case local file opening a popup from Intranet.

window.open returns a reference object even if Enable Protected Mode is checked when yoursite. opens someothersite. in popup window i.e. Internet->Internet

You can use window.showModalDialog as a alternative or replacement for window.open method.

It is more secure then window.open. It will not allow user clicking the Parent page.

Example Usage:

var myFeatures = "dialogWidth:1060px;dialogHeight:550px;resizable:yes";

window.showModalDialog(url,window,myFeatures);
       //Here window is an object, no need to assign or declare.

If you want more detail explanation see Here. //Fifth Question.

发布评论

评论列表(0)

  1. 暂无评论