开发者

how to throw an alert saying " please turn off the pop up blocker" [duplicate]

开发者 https://www.devze.com 2022-12-27 23:05 出处:网络
This question already 开发者_如何学Chas answers here: Closed 10 years ago. Possible Duplicate: How can I detect if a browser is blocking a popup?
This question already 开发者_如何学Chas answers here: Closed 10 years ago.

Possible Duplicate:

How can I detect if a browser is blocking a popup?

hi iam trying to open a child window with disabled toolbar.......

how to check whether the child window is opened or not and then display this alert??

can someone help with code.........


When you create a new window using window.open(), it returns a handle to the (theoretically) opened window. You can then test that handle to determine whether the window is open:

var child = window.open("mypopup.html");

// some popup blockers prevent the window from being created (!child) and
// others just close them before they're displayed (child.closed)

if (!child || child.closed) {
    // tell the user to turn off their popup blocker
}

Popups are very intrusive, however, and you should consider trying to display the "popup" information within the page. In particular, have a look at "dialog" scripts. If you're using jQuery, a very nice Dialog widget is included in the jQuery UI library.


I think, if popups are blocked, window.open() will return a null, not a window object. You can read it in an MSDN article:

If you are not sure whether a pop-up window is blocked, check your functions that return a window object. You can tell if a pop-up window has been blocked if these functions return null. In particular, you need to check the value of window.open to avoid script errors when your pop-up windows are blocked.

Also, this will give you some hints about detection of popup blockers: http://www.visitor-stats.com/articles/detect-popup-blocker.php


You need to give us the Javascript you are using so that we can help. You will need an 'if' statement.

Display alerts like this in javascript:

alert('Please turn off your pop-up blocker');

0

精彩评论

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

关注公众号