I have a page with an IFRAME that points to another site. is there a way to create a link on a sperate page that would open the page with the IFRAME but change the content of the IFRAME?
I have a page with an IFRAME that points to another site. is there a way to create a link on a sperate page that would open the page with the IFRAME but change the content of the IFRAME?
i think your referring to:
<a href="http://url.here" target="iFrame_name">Link</a>
from what you've described, you need the target="***" bit. the *** being the name of your iFrame.
if this isnt what your after, let me know and we'll discuss it :-)
That's not really what I'm looking for. That works if the link and the frame are in the same .html file. Let me try to explain better. say I have a home.html file and a store.html file. The store.html has the frame that defaults to the store index page. I wnt to put a link on the home.html that points to the store.html but changes the content of the frame form the index page to a spacific product page.
You can do it with .php files.
links:
store.php?q=apples
store.php?q= cherries
store.php puts out basically the same html it does now, just adjusting the src attribute in the IFRAME tag.
PHP Code:
<?php
if( isset( $_GET['q'] ) ){
$src = $_GET['q'] . ".html" ;
} else {
$src = "default_product.html" ;
}
?>
<iframe src="<?php echo $src ?>" width="100%" height="300">
<p>Your browser does not support iframes.</p>
</iframe>
Nothing is always absolutely so.
Hi "james70",
If you want to use just HTML and JavaScript for your codes, try the followings:
Hope this helps.
- First, in your "home.html" HTML document, use "?url=some product.html" (it DOESN'T have to be "url=some product.html" specifically - I just use it as an example) in the HTML <A> tag after the link ("store.html") to pass the URL of the page that you want to show in your "store.html"'s <IFRAME> to the "store.html" HTML document,
Code:<A href = "store.html?url=some product.html"></A>- Second, in your "store.html" HTML document, use JavaScript to parse the "window.location.href"'s (or more specifically, "window.location.search" - don't know if this attribute/property is available in other browsers besides Microsoft Internet Explorer or not) result string to fetch the passed URL and feed it to the page's <IFRAME>'s src (let me know if you need further help on this).
►Website: http://losthorizon.cz.cc/
"Genius is one percent inspiration and ninety-nine percent perspiration" -- Thomas Alva Edison.
Thanks. you've been a lot of help.
Below is the code I ended up using:
<iframe src="http://defaultpage" width="100%" height="850" id="inframe">
<p>Your browser does not support iframes.</p>
</iframe>
<script language="javascript" type="text/javascript">
var query = window.location.href.split("?");
var params = query[1].split("url=");
document.getElementById('inframe').src = params[1];
</script>
Link: <a href="http://mysite/?url=http://storesite/page">LINK</a>
I hope this helps someone else.
Nicely done "james70",
Also, it's very NICE of you (very COMMENDABLE) to present the solution here as well so others can benefit from it.
►Website: http://losthorizon.cz.cc/
"Genius is one percent inspiration and ninety-nine percent perspiration" -- Thomas Alva Edison.