tags:

views:

4854

answers:

1

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.

+2  A: 

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 come from the same origin.

Tomalak