1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Loading into Another Frame

clr gif
Join the Discussion

Questions? Comments?

To load another page over the current one using Javascript you assign the URL of the new page to be loaded to location.href like this:

location.href = 'newpage.htm';

If your page uses frames then things are slightly more complicated because using the above code results in the content of the current frame being replaced. How do we handle it if we want to replace the whole page with a new one and not just the current page? Well we can use parent.location.href to refer to the whole page like this:

parent.location.href = 'newpage.htm';

The other situation (and perhaps the more likely one) when you are using frames is where you want to replace the content in a different frame. Well as long as we have named each frame then this becomes relatively easy too. Lets say that we have the frame that we want to change defined in the frasmeset like this:

<frame name="main" id="main" src="main.htm" />

We can now easily refer load a new page into this frame from a Javascript running in another frame like this:

parent.main.location.href = 'newpage.htm';

You just need to make sure that the codes in bold are different for each frame and that you refer to the right one in your code.

Related Video
Adobe Photoshop Photo Frame

©2017 About.com. All rights reserved.