The problem I am facing is when I try to do something like the code below, the window is blocked by pop-up blockers. I use getScript to execute cross domain requests. I am using jQuery 1.4.2 to execute below.
Example code to be blocked:
$(document).ready(function(){
$(".popup").click(function(){
$.getScript("URL_To_A_Javascript_File", function(){
window.open("dynamicURL", "_blank");
});
});
});
An example of code that passes blockers but does not get the URL in time:
$(document).ready(function(){
var url;
$(".popup").click(function(){
$.getScript("URL_To_A_Javascript_File", function(){
url = "dynamicURL";
});
window.open(url, "_blank");
});
});
How to open a new window using the URL created inside the getScript callback function and avoid pop-up blocking?
source
share