Forum Moderators: open
I have this page (resume.htm) displayed inside an iframe on a page (cv.shtml). There are several anchor tags inside resume.htm for in-page navigation convenience.
I need to find a way how I can link into a particular anchor tag inside resume.htm (for example: resume.htm#education) by linking into cv.shtml first, and then displaying the particular anchor on resume.htm. Any help on this matter is much appreciated! Thanks in advance!
Make sure your anchors have names (e.g. name="great-things-about-me").
Put this script in your head :
<script type="text/javascript">
function ifill(iframe,page) {
eval("parent."+iframe+".location='"+page+"'");
}
</script>
Give your iframe a name :
<iframe name="i" src="resume.htm" height="500px" width="100%"></iframe>
Add a link :
<a onclick="ifill('i','resume.htm#great-things-about-me')" href="#">Great things about me</a>
And er... that's it.
This worked when I tested it, so if you have any problems, let me know and I'll try to explain more clearly.
Cheers.
I have resume.htm as the source of iframe on cv.shtml. Say for example, I have index.shtml (and index.shtml doesn't have any iframes), how do I add a link in index.shtml that will take me to a particular anchor position in resume.htm (such as resume.htm#technical), but will show that in cv.shtml? I hope I was clear in explaining this as succinctly as possible!
I've got to learn javascript real soon, sigh :(.
You will need to add the following code to resume.htm. I would place it at the end of the HTML.
function loadIframe()
{ i.location.href = unescape(document.location.query) }
where i is the name of the iframe.
Note that '%23' is translated into '#'
Kaled.
<added>
Would it be better to use <iframe id="subframe">
and then use
var i = getElementById('subframe');
</added>