jquery window.open in ajax success being blocked
For opening a new URL in the window you opened in onclick
, do the following
- Store the new window you created in a variable
var newWindow = window.open("","_blank");
- Change the location of the new window
newWindow.location.href = newURL;
One additional thing that can be done to improve user experience is to send the new window to background immediately (newWindow.blur
) after opening and then bring it in foreground again (newWindow.focus
) while opening the URL the the new window.
Do a window.open("about:blank", "newPage");
before the AJAX call and then after the call add the URL to the opened window by calling window.open("http://google.com", "newPage");
.