views:

163

answers:

2

Suppose we have frameset of with 2 frames, one frame is kind a tiny horizontal header and second is kind of "content" frame with 3rd-party html page inside. When user clicks on some link inside "content" frame, the whole page (frameset) should be reloaded with this link, the same behavior if "content" frame has "target=_top" attribute. How to do this using JS?

The main problem here is - that I can't edit html of "content" page.

A: 

Try setting window.location to the target URL.

lexicore
I think you mean `window.top.location`
Pointy
don't understand you point
abovesun
A: 

Here is my quick solution:

<html>
<head>
<script type="text/javascript">
    function load(){
        // set target="_top" to reload whole frame
        var links = this.content.document.getElementsByTagName("a");
        for(var i = 0; i < links.length; i++){
            var link = links[i];
            link.target="_top";
        }
    }
</script>
</head>

<frameset rows="50,*" frameborder="0" onload="load()">
   <frame src="/header.html" scrolling="no">
   <frame src="/content.html" name="content">
</frameset> 

</html>
abovesun