开发者

JS and Body(Window) Onload event

I have a problem with onload event. My page have 4 iframes a开发者_开发问答nd the function from onload event is called 5 times ( one for body and 4 for iframes ). I want only 1 time ( from main body ). Try with srcElement and target property from windows.event but no result... Is there a way to stop onload when iframes load?

Code:

<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>

all Iframe have the same code like this in code. i try to use a code from http://dean.edwards.name/weblog/2005/09/busted/ to check done but the init function is called five times again


You want to check if the current window is the topmost window, which you find by checking against window.top:

function init()
{
    if (this === window.top)
    {
        // This is the main body (not in an iframe)
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜