jquery window.open in ajax success being blocked

后端 未结 3 1725
我在风中等你
我在风中等你 2020-12-01 09:41

Trying to open a new browser window in my ajax success call, however, it is blocked as a popup. I did some searching and found that a user event needs to be tied to the win

3条回答
  •  暖寄归人
    2020-12-01 10:03

    For opening a new URL in the window you opened in onclick, do the following

    1. Store the new window you created in a variable var newWindow = window.open("","_blank");
    2. 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.

提交回复
热议问题