简体   繁体   English

Javascript Window.open问题IE7 / IE8

[英]Javascript Window.open Issue IE7 / IE8

I have created a simple JQuery script that loops through an array of urls and opens multiple windows. 我创建了一个简单的JQuery脚本,该脚本遍历URL数组并打开多个窗口。

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. 但是,在客户端计算机上的IE7和IE8中,浏览器仅打开一个窗口。 No javascript errors are present. 没有javascript错误。

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 受影响的计算机: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. 这会产生问题,但是如果您放置一个变量,则每次都会获得新的引用,并且jquery循环中的所有内容都可以正常工作。

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: 但是以下内容在所有可用的浏览器(包括Firefox 3.5,Opera 10,Chrome 3和Internet Explorer 6、7和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) 将ID分配给Windows并重复使用相同的ID->分配不同的ID(如果不需要,则不分配)
  • Opening unrequested popups -> Let the user trigger the action 打开不需要的弹出窗口->让用户触发操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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