Forum Moderators: open
how do i make a link outside of iframe at near bottom that changes the iframe's link and automatically scrolls the browser up at the same time?
i hope i'm being clear.. basically i want to href="\test.php" & href="#main" at the same time w/ one click.. is that possible?
thanks guys
<a href="http://some.where/some/place/1/" target="iframe"><img src="img1.gif" alt="Click me"/></a>
<a href="http://some.where/some/place/2/" target="iframe"><img src="img2.gif" alt="Click me"/></a>
<a href="http://some.where/some/place/3/" target="iframe"><img src="img3.gif" alt="Click me"/></a>
...
<iframe id="iframe" name="iframe" src="about:blank"></iframe>
If that is the case, you can do what you want with a bit of script magic. Put this in the <head> of the document:
<script type="text/javascript">
<!--
function getSelf() {
var mySelf = null;
if (document.location.href.indexOf("#") > -1)
mySelf = document.location.href.substring(0, document.location.href.indexOf("#"));
else
mySelf = document.location.href;
return mySelf;
}
function goanchor(anc) {
var mySelf = getSelf();
if (mySelf.indexOf("#") > -1)
mySelf += anc;
else
mySelf += ("#" + anc);
document.location.href = mySelf;
return true;
}
//-->
</script>
And then change your links like this:
<a href="http://some.where/some/place/1/" target="iframe" onclick="return goanchor(this.target);"><img src="img1.gif" alt="Click me"/></a>
<a href="http://some.where/some/place/2/" target="iframe" onclick="return goanchor(this.target);"><img src="img2.gif" alt="Click me"/></a>
<a href="http://some.where/some/place/3/" target="iframe" onclick="return goanchor(this.target);"><img src="img3.gif" alt="Click me"/></a>
...
<iframe id="iframe" name="iframe" src="about:blank" class="frame"></iframe>