Window length Property - Loop through all frames on a page, and change the location of all frames - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window length

Description

Window length Property - Loop through all frames on a page, and change the location of all frames

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>
<br><br>

<iframe src="https://www.cnn.com"></iframe>
<iframe src="https://www.bbc.com"></iframe>
<iframe src="https://www.nytimes.com"></iframe>

<script>
function myFunction() {//from   w ww  .  j ava2  s  .  c  o  m
    var frames = window.frames;
    var i;

    for (i = 0; i < frames.length; i++) {
        frames[i].location = "https://www.java2s.com";
    }
}
</script>

</body>
</html>

Related Tutorials