# External link to iFrame - How to!

**URL:** <https://forum.kirupa.com/t/external-link-to-iframe-how-to/197363>\
**Category:** web dev\
**Created:** [August 15, 2006, 8:51pm UTC](https://forum.kirupa.com/t/external-link-to-iframe-how-to/197363 "2006-08-15T20:51:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlashMom](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@FlashMom](https://forum.kirupa.com/u/FlashMom)\
**Post date:** [August 15, 2006, 8:51pm UTC](https://forum.kirupa.com/t/external-link-to-iframe-how-to/197363/1 "2006-08-15T20:51:25Z")

</div>

Trying to create a text link from an external webpage to target a certain page in the iframe? Here is how you do it.

NOTE: Please bare with me I’m writing this for people who don’t necessarilly understand code. ![](http://www.programmingtalk.com/pt_images/images/smilies/wink.gif)

Note: We are using these filenames:  
index.html = the file with the iframe  
default.html = the file that the index.html file loads in the iframe if nothing else is specified,  
finalcontent.html = the file you want to be loaded in the iframe of the index file (not the default file)  
textlinkfile = the text link that will link to the index file and the targeted finalcontent.html file for the iframe  
bob = the name I gave to the iframe.(I like to use something original so I can find it in the code later when I need to make changes)

STEP ONE:  
Put this javascript code in your index.html file:

\<script language=javascript\>function loadsource()  
{  
var defaultPage = “default.html (Enter the filename you want as your default here)”;  
var query = window.location.search.substring(1);  
var pos = query.indexOf(’=’);  
if (pos \> 0)  
{  
var frameSource = query.substring(pos+1);  
window.frames[“bob”].location = frameSource;  
}  
else  
{  
window.frames[“bob”].location = defaultPage;  
}  
}  
\</script\>

STEP TWO:  
Enter this into the body tag:  
\<body onLoad=“loadsource()”\>  
(For non-tech people, make sure there is only one body tag and enter just this part: onLoad=“loadsource()”)

STEP THREE:  
Now on the external textlinkfile add this to the text link:  
\<a href=“index.html?fs=finalcontent.html”\>Recipe\</a\>  
Make sure you include the entire path. So if your file is in a folder include that: example - \<a href=“index.html?fs=folder/finalcontent.html”\>Recipe\</a\>

Test it. It should work!!!

Let me know if this has helped you!  
FlashMom
