How can I open a new window using a URL that is generated inside the getScript callback function, and avoid pop-up blockers?

后端 未结 3 524
我寻月下人不归
我寻月下人不归 2021-01-18 20:49

The issue I am having is when I try to do something like the below code, the window will be blocked by pop-up blockers. I am using getScript so that I can make cross domain

3条回答
  •  情歌与酒
    2021-01-18 21:32

    Ok, it looks like I finally figured out how to do what I was trying to do.

    This way allows me to do the pop-up with out the need for an intermediate page that handles the javascript.

    var newWin;
    $(document).ready(function(){
        $(".popup").click(function(){
            newWin = window.open();
    
            $.getScript("URL_To_A_Javascript_File", function() {
                newWin.location = "DynamicURL";
            });
            return false;
        });
    });
    

提交回复
热议问题