My javascript code is like this:
function openWindows() {
if(A is true) {
window.open(URL_A);
}
if(B is true) {
window.open(URL_B);
}
and so on...
}
When my function is called, with all conditions true, random no. of windows open. Some times, all of them open but it happens randomly. What could be the issue? Am I losing the parent window reference? Why is this happening randomly?
Works fine for me.
Are you sure your popup blocker isn’t stopping them? Many browsers don’t allow you to trigger new windows without a click event or the browser will stop them. Also, the browser usually allows one window per click event.
http://jsfiddle.net/2LJtv/ ( warning be prepared for 4 windows to open )