on('load')对于Internet Explorer 11中打开的弹出窗口不起作用 [英] on('load') does not work for opened popup in internet explorer 11

查看:84
本文介绍了on('load')对于Internet Explorer 11中打开的弹出窗口不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不记得上次我用弹出窗口做什么,但是:(

I do not recall the last time I used popup for anything, but :(

我想打开新窗口,当它打开时我想喊出来 1。窗口在所有浏览器中打开,但在IE 11 / Edge中它不会警告()。

I want to open new window and when it is opened I want to shout "1". Window opens in all browsers, but in IE 11 / Edge it does not alert().

<html>
<head>
<script src="//code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
$(document).ready(function(){
  $('#button').on('click',function(e){
    e.preventDefault();
    var win = window.open ('/test.html')
    $(win).on('load',function(){
      alert ('opened');
    });
  });
});
</script>
</head>
<body>
<a href="#" id="button">button</a>
</body>
</html>


推荐答案

正在发生因为IE11(并且可能是Edge)没有从窗口打开调用返回,直到窗口打开已经完成你没有调用你添加的加载事件处理程序,因为事件已经被触发了。

The is occurring because IE11 (and presumably Edge) is not returning from the window open call until the window opened has finished loading. The load event handler you add is not called because the event has already fired.

文件之后:协议文件一直要求允许允许阻止内容并使IE崩溃,使用localhost node.js / express服务器恢复测试。

Afterfile: protocol files kept asking for permission to allow blocked content and crashing IE, testing resumed using a localhost node.js/express server.

结果通过加载事件进行验证test.html中的监听器,其中包括将test loaded< br>附加到DIV元素的内容的代码,并将代码放入单击处理程序以将window opened< br>附加到同一个DIV中,在打开的页面中,窗口打开电话后立即。

The result was verified by putting a load event listener in test.html which included code to append "test loaded<br>" to the contents of a DIV element, and putting code in the click handler to append "window opened<br>" to the same DIV, in the page opened, immediately after the window open call.

IE按顺序报告测试加载,窗口打开。 Firefox在开始页面中引发了一个错误,即用于登录已打开页面的DIV元素尚未存在(如预期的那样)。

IE reported "test loaded, window opened" in that order. Firefox threw an error in the opening page that the DIV element used for logging in the opened page did not exist yet (as expected).

很难建议编码解决方案,不知道窗口间访问需要实现什么,以及您控制和修改哪些文件。知道问题所在应该有所帮助!

It is difficult to suggest a coding solution without knowing what needs to be achieved by the inter-window access and what files you control and can modify. Knowing what the problem is should help!

这篇关于on('load')对于Internet Explorer 11中打开的弹出窗口不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆