简体   繁体   中英

Javascript Window.open Issue IE7 / IE8

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

可能启用了弹出窗口阻止程序

如果我没记错的话,那么IE7 +中的弹出窗口阻止程序在javascript中每次用户互动仅允许一个新窗口,然后将其阻止。

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.

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">
<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"></script>
<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM