【发布时间】:2011-03-24 14:36:59
【问题描述】:
这篇文章与window.onload() is not firing with IE 8 in first shot相关。
从主页(窗口)中打开一个新窗口:
... window.open('foobar.php',<...>); ...
新窗口已正确打开,但 window.onload() 部分(位于 'foobar.php' 中)中的代码未执行:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>foobar</title>
<script type="text/javascript">
//<![CDATA[
window.onload = function ()
{
alert('foobar');
}
//]]>
</script>
</head>
<body>
</body>
</html>
用 Prototype 的“document.observe('dom:loaded', function()”和 body-Tag 中的“onload”属性替换“window.onload”也不起作用。如果我重新加载内容新打开的窗口或再次打开它,然后代码工作正常。如果我从主窗口中运行代码,那么代码也工作正常。这似乎是一个缓存问题,但我不确定。
我的 IE 版本是 8.0.6001.18702。我已经推迟了所有的附加组件。
在此先感谢
【问题讨论】:
-
抱歉,有点不清楚。 window.open('foobar.php');上面的代码位于'foobar.php'。
-
请发布
window.open的确切代码。
标签: javascript internet-explorer-8 window.open