sitemap | tutorials | transfer money | hosting/websites/e-Commerce | sponsor a child | weblog | back |  Privacy-About-Contact
My Best Host |  Whispering Wall |  Brithney Spers |  She Wolf of the SS |  Flora and Fauna of Bolivia |  Models |  Glass Blowing

How Do I "Target an iFrame"

Click here to see the same tutorial in JavaScript instead of PHP

If it is in the same window, just use target="(put iFrame name in here)" in the URL.

How Do I "Target an iFrame" in another window on a different web page/site.

You need to do two things:

1. Pass the URL of the iFrame(target "src") as a variable added to the link.
2. Detect the variable info and insert it when it gets there.

E.G. I have an Amazon aStore inside an iFrame on my online-store page. Just linking to online-store goes to the general items, but I want to link directly from my tutorial page to a specific product in my aStore shop.

On my tutorial page I link to the aStore shop site(online-store etc), and add the product URL as a variable (named "content"), like this.

<a href="http://online-store etc/?content=http://astore.amazon.com/mylogin-20/&node=11/"> Product Link </a>

This link contains a variable named "content" with a URL as information to be passed. The name "content" is the name(ID) of the target iFrame.

On the target page you will need a little script to detect the variable and then write it into the page where the iFrame goes.

<?php
$content = $_GET['content'];
if ($content =='')
\\ Looks to see if content is present. If no content, write the iFrame normally
echo '<iframe src="http://astore.amazon.com/mylogin-20/" name="content" frameborder="0" width="800px" height="800px" ></iframe>';
\\ If content is present, writes the iFrame using the URL passed from the original link.
else
echo '<iframe src="',($content),'" name="content" frameborder="0" width="800px" height="800px" ></iframe>';
?>

NOTES:
1. Some browsers require the iFrame to have an ID, so it is safer to add id="content" as well as name="content".
2. You may need to replace any Ampersands or underscores in the URL with HEX code -I.E.,
replace "&" with "%26"
replace "_" with "%1F"
You will need to rename your target.htm page to target.php, for this code to work; or else use JavaScript intead of PHP.

Try it here --> MicroSoft FrontPage search in my Online-Store