开发者

is window.open("", ... impossible with firefox?

In firefox I have opened a locally stored file with the file:// protocol (file:///c:/temp/foo.html)

foo.html contains Java Script which (among others) is supposed a new window without URL:

var new_window = window.open("","", "height=100,left=50,width=200");

When this line is reached, Firefox displays this "Firefox prevented this site from opening a pop-up window". I don't understand why Firefox gives this warning, obviously, the file (foo.html) is under my control (since it's stored locally and I have opened it with the file:// protocol, and, additionally, the window to be opened doesn't poi开发者_开发百科nt to any file that could contain any sensitive data, as the url parameter in the open method is set to "".

But besides all this, it seems I can't even force or allow firefox to open the window anyway. There's this "options" button on the yellow "Firefox prev...." bar which supposedly should allow to create exceptions, yet I can't.

So, the question basically boils down to: how can I allow a local html file to open an empty window with Javascript within Firefox.

Thanks / Rene


This is a Firefox security precaution, see this link:

http://kb.mozillazine.org/Links_to_local_pages_don't_work

However, it looks like this extension will allow you to override it:

https://addons.mozilla.org/en-US/firefox/addon/281


This is the popup blocker, which block popups not opened by an explicit user action like a click. You cannot force it to open the popup, you need to allow Firefox to open it. I suggest you to test the new_window variable to see if it is null. In this case, display a message to the user so that he allows the domain to open popup windows.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜