window.close重新实现在IE9标准文档节点中不起作用。 [英] window.close reimplementation not working in IE9 Standards document node.

查看:73
本文介绍了window.close重新实现在IE9标准文档节点中不起作用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

尝试使用IE9中的"IE9标准"下面的网页。文档模式的结果是触发了默认的window.close行为。将文档模式更改为任何其他自定义函数将按预期触发。

trying to use a web page like the one below in IE9 with "IE9 Standards" document mode the result is that the default window.close behavior is fired. Changing document mode to any other the custom function is fired as expected.

相反,window.open可以正常工作。

Same thing with window.open works instead.

我找不到在IE9中无法重新定义window.close函数的任何地方,我做错了,我无法看到?

I can't find anywhere that in IE9 is not possible to redefine window.close function, I'm doing something wrong that I'm not able to see?

提前致谢


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html>

<head>

<script>

window.close=function ()

  {

    alert('close');

  }

</script>

</head>

<body>

<input type="button" onclick="window.close()" value="close"></input>

</body>

</html>

推荐答案

您好SBGibson,

Hi SBGibson,

感谢您的帖子。

问题是窗口确实存在,直到它关闭了,窗口关闭后javascript不再存在。因此无法调用提醒。

The issue is that the window does exist until it is closed, and javascript no longer exists after the window closes. so the alert can not be called.

然而, 有一个onunload方法在页面被卸载之前立即触发,例如:

However,  there is an onunload method that fires immediately prior to a page being unloaded, for example:

< body onunload =" alert('close');">

<body onunload=" alert('close');">

有关卸载事件的更多信息,请参阅MSDN文章:
http://msdn.microsoft.com/en-us/library /ms536973%28v=vs.85%29.aspx

for more about unload event please refer MSDN article: http://msdn.microsoft.com/en-us/library/ms536973%28v=vs.85%29.aspx

希望这有帮助,谢谢。


这篇关于window.close重新实现在IE9标准文档节点中不起作用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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