
Originally Posted by
Peter Johnson
One last question though -
Is there any way to write it so that the link in the iframed page (iframe.html) would work whether the page was framed or not, in other words even if the page stood on its own and wasn't part of main.html?
iframe.html:
Code:
<html>
<body>
<a href="#hi" onclick='if (parent.gotoAnchor) {parent.gotoAnchor("hi"); return false;}'>click here</a>
1<br>
2<br>
3<br>
4<br>
5<br>
6<br>
7<br>
8<br>
9<br>
10<br>
11<br>
<a name="hi">
12<br>
13<br>
14<br>
</body>
</html>
iframes.html
Code:
<html>
<head>
<script type="text/javascript">
function gotoAnchor(aname)
{
var yScroll = document.body.scrollTop;
var xScroll = document.body.scrollLeft;
document.getElementById("theframe").src="iframe.html#" + aname;
self.scrollTo(xScroll, yScroll);
}
</script>
</head>
<body>
<iframe id="theframe" src="iframe.html" width="100px" height="100px">
</iframe>
</body>
</html>
Bookmarks