Forum Moderators: open
So is there a way in which i can do this?
thanks
Raff
is there a way i can combine the target link as well as using a anchor link to snap to the bottom of the page where the iframe is.
hope you understand
thanks
raff
OK, I think I understand. You have something like this, correct?
<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>
This way, for users with JavaScript enabled it will scroll down to the iframe, but if a user doesn't have JS enabled, the links will still work as expected, it just won't scroll to the iframe.
HTH
Jordan