admin管理员组

文章数量:1323224

Is there a way to reload an entire frameset using Javascript onload() event?

function logout() {
    /* ... */
    // reload entire frame
    top.location.reload();
}

<body onload="logout()">

This cause all frames to reload but the URL of the frame where this was called didn't changed to the URL specified in the framset.

Is there a way to reload an entire frameset using Javascript onload() event?

function logout() {
    /* ... */
    // reload entire frame
    top.location.reload();
}

<body onload="logout()">

This cause all frames to reload but the URL of the frame where this was called didn't changed to the URL specified in the framset.

Share Improve this question edited Sep 20, 2017 at 22:38 P.S. 16.4k14 gold badges65 silver badges86 bronze badges asked Sep 26, 2008 at 9:29 ksuraltaksuralta 17.2k16 gold badges41 silver badges36 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

As I understood it, you want to reload each frame in a frameset using the original URL as stated in <frame src="...">.

This little function can do that (put it into the document holding the frameset):

this.reloadChildFrames = function()
{
    var allFrames = document.getElementsByTagName("frame");
    for (var i = 0; i < allFrames.length; i++)
    {
        var f = allFrames[i];
        f.contentDocument.location = f.src;
    }
}

You are then able to call that function from within any child frame:

top.reloadChildFrames()

Of course, this can only work when all frames e from the same origin.

本文标签: