views:

740

answers:

4

Hi,

I have created a simple JQuery script that loops through an array of urls and opens multiple windows.

This is working fine on the majority of platforms.

However, in IE7 and IE8 on a client's machine the browser is only opening a single window. No javascript errors are present.

I have the same versions on my laptop and it works fine.

Please could someone shed any light on potential factors?

Affected machines: XP SP3 - IE 7 Final, Windows 7 IE 8

Any help would be greatly appreciated.

Cheers Paul

+2  A: 

There might be a popup blocker enabled

marcgg
+1  A: 

Not sure but are you assigning each new reference of a window to a variable? This creates problems but if you put a variable, it gets new reference each time and things inside jquery loops work fine.

Sarfraz
I have updated the code as follows:myWin = window.open(url, i+term.replace(/[^a-zA-Z0-9]+/g,'_'));
Mindblip
Waiting to hear back from client, is this what you meant?
Mindblip
yes that's what i meant.
Sarfraz
+2  A: 

If I remember correctly, the popup blocker from IE7+ allows just one new window per user interaction in javascript, and then blocks them.

Jerome
+1  A: 

Sorry, I can't follow your one-line unformatted code. But the following does work in all browsers I have available including Firefox 3.5, Opera 10, Chrome 3 and Internet Explorer 6, 7 and 8:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
<html lang="es">
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript"><!--
function openLinks(){
    var linkList = [
     "http://www.google.es",
     "http://www.yahoo.com",
     "http://www.bing.com",
     "http://stackoverflow.com",
     "http://serverfault.com/"
    ];

    $(linkList).each(function(){
     window.open(this);
    });
}
//--></script>
</head>
<body>

<input type="button" onclick="openLinks()" value="Open lots of links">

</body>
</html>

Typical mistakes related to popup windows include:

  • Assigning IDs to windows and reusing the same ID -> Assign different IDs (or none if not needed)
  • Opening unrequested popups -> Let the user trigger the action
Álvaro G. Vicario