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 requests. I am using jQuery 1.4.2 to do the below.
Example of code that will be blocked:
//Code that gets blocked by pop-up blockers
$(document).ready(function(){
$(".popup").click(function(){
$.getScript("URL_To_A_Javascript_File", function(){
window.open("dynamicURL", "_blank");
});
});
});
Example of code that gets past blockers, but doesnt get URL in time:
//This code will get past the pop-up blocker, but the var url won't be updated
//with the dynamicURL before the window.open() fires in browsers
//like safari or chrome.
$(document).ready(function(){
var url;
$(".popup").click(function(){
$.getScript("URL_To_A_Javascript_File", function(){
url = "dynamicURL";
});
window.open(url, "_blank");
});
});
How can I open a new window using a URL that is generated inside the getScript callback function, and avoid pop-up blockers?