View Full Version : Help with loading in iframes.

03-22-2005, 02:50 AM
What's the javascript to make links that are clicked in the navbar, open in the iframe?

03-22-2005, 03:04 AM
Can be done without javascript, just plain HTML.

<a href="thepage.html" target="nameOfTheIframe">link</a>

03-22-2005, 03:51 AM
For some reason, that wouldnt work for me, so I used,

<script type="text/javascript">
function loadIframe(iframeName, url) {
if ( window.frames[iframeName] ) {
window.frames[iframeName].location = url;
return false;
else return true;


<A HREF="url" TITLE="title" onclick="return loadIframe('frame', this.href)"><IMG ALT="alt" SRC="img.url" WIDTH="" BORDER="" HEIGHT=""></A>

Thanks anyways though.

03-22-2005, 04:03 AM
Although it sounds like it worked, you might want to find a non-javascript alternative, as some ppl have javascript disabled and it will make your site look nothing like what it looks like for someone with javascript enabled :)

03-22-2005, 05:05 AM
For some reason, that wouldnt work for me, so I used,

It should work. Did you specify the name (not the id) of the iframe in the target?

As Scootertaj mentioned, you should provide a non-javascript alternative as it can be disabled. And my suggested solution is the answer.