I have a page that contains an iframe element. I want to have some text on the main page when clicked to change the iframe source. I can do that with an "a href" tag but the main page resets to the top instead of where the user was last on the page vertically. If I use an input type=button element, then it works just fine without resetting to the top of the main page. However, I want the look of just text on the page (with an underline) instead of a button look. How can I do this?
+2
A:
use target
<a href="page2.html" target="test">Go to page 2</a>
<iframe src="page1.html" frameborder="0" name="test"></iframe>
Luke Schafer
2009-08-05 02:06:44
A:
you can use a div or span (actually pretty much any element) instead of a button
<div onclick="iframe.src='new.html'" class="lookcool">sometext</a>
Niko
2009-08-05 02:07:19
A:
Not sure what you have done so far, but it seems like you want to change the page displayed in an iframe. To do that with a link, you can use target or javascript:
Target:
<a href="http://www.google.com" target="iframe">link</a>
<iframe name="iframe" src="http://www.example.com" />
Javascript:
<a href="#" javascript="document.getElementById('iframe').src='http://www.google.com'; return false;">link</a>
<iframe id="iframe" src="http://www.example.com" />
Marius
2009-08-05 02:08:34