Javascript JS和Body(窗口)Onload事件
我对onload事件有问题。我的页面有4个iframe,onload事件的函数调用了5次(一次用于body,4次用于iframe)。我只想要一次(从主体)。尝试使用windows.event中的srcElement和target属性,但没有结果。。。当iFrame加载时,是否有停止onload的方法 代码:Javascript JS和Body(窗口)Onload事件,javascript,Javascript,我对onload事件有问题。我的页面有4个iframe,onload事件的函数调用了5次(一次用于body,4次用于iframe)。我只想要一次(从主体)。尝试使用windows.event中的srcElement和target属性,但没有结果。。。当iFrame加载时,是否有停止onload的方法 代码: ... ... ... 所有Iframe在代码中都具有与此相同的代码。我尝试使用来自的代码 要检查是否完成,但再次调用init函数五次您要检查当前窗口是否是最顶部的窗口,您可以通过检查找
...
...
...
所有Iframe在代码中都具有与此相同的代码。我尝试使用来自的代码
要检查是否完成,但再次调用init函数五次您要检查当前窗口是否是最顶部的窗口,您可以通过检查找到:
您要检查当前窗口是否是最顶部的窗口,您可以通过检查以下内容来查找:
iframes是空的,我使用它们作为Ajax上传的示例iframes是空的,我使用它们作为Ajax上传的示例
<body onload="init()">
<div id="dialogs">
<div id="login">
<FORM id="loginform" name="loginform" action="alogin.php" method="post" target="login_target">...</FORM>
<iframe id="login_target" name="login_target" src="#"></iframe>
</div>
...
...
</body>
function init()
{
if (this === window.top)
{
// This is the main body (not in an iframe)
}
}