Reputation: 47945
If I have an handler on a link that open via javascript a popup windows, all works. But, if inside the handler, I do an ajax request, and than after complete it I open a new window, the browser block it. I open it with:
openedWindow = window.open("/interne/appsocial/aggrega/Aggrega" + pageTitle + ".aspx", "popup", "width=" + popupYTSizeWidth + ", height=" + popupYTSizeHeight + ", top=" + top + ", left=" + left);
do you know why? And can I fix this trouble?
Upvotes: 1
Views: 513
Reputation: 96271
If I have an handler on a link that open via javascript a popup windows, all works. But, if inside the handler, I do an ajax request, and than after complete it I open a new window, the browser block it.
Popup blockers in current browsers by default tend to allow popups when they are triggered by explicit user interaction, f.e. clicking on a link – it can be assumed, that this is more likely a popup the user actually wants to open, than a popup that would open just “out of the blue”, which will more likely be annoying/spam.
But since your AJAX request is asynchronous, there is no more direct connection between the click your user makes, and the opening of the popup – that happens much later, after the original code block that was triggered by clicking has finished execution. And therefor it gets blocked, because the browser can’t differentiate it from the other kind of “bad” popups that get openend without user interaction.
Upvotes: 4