Skip to content Skip to sidebar Skip to footer

Ajax Popup Blocked In Ie, But Not In Ff

Following code displays two buttons: AJAX popup and Direct popup. They are supposed to open the same page in a new window. Direct popup calls just window.open() in onclick event. A

Solution 1:

As you suggest, this is due to the second window.open not being in direct response to user activity.

One approach would be to open the window in the click handler, before starting the Ajax call, set to display a "Loading..." message. Then, when the URL is received from the Ajax call, point the popup to where it should be - assuming you do:

var popup;

functionloadXMLDoc(url) {
    popup = window.open("loading.html");
    // and all the Ajaxy bits after that...
}

then all you need is

function stateChanged() {
    // the readystate stuff...var ultimateUrl = /* grab stuff from Ajax response */;
    popup.location.href = ultimateUrl;
}

Solution 2:

The reason why is the new window is delayed from the initial click event. That delay causes the browser to not associate the click event with the new window and will block it. There is no way around it other than asking the user to mark your site as safe.

So your trick to see if the page is there before you open it will not work. You can try doing a synchronous request, but that is probably will cause worse issues than a blocked pop up window.

Post a Comment for "Ajax Popup Blocked In Ie, But Not In Ff"