Forum Moderators: open
I have a plain index page with hyperlinks. Then I have an index2 page with nothing but a navigational bar.
What I want is each hyperlink on index.html to point specifically to a certain iframe. For instance, if I have a "Contact Me" hyperlink on index.html, I want index2.html to pop up, with contact.html in its own iframe. Since I have multiple links on index.html, I want each hyperlink to load index2.html with its corresponding iframe.
Is there some kind of target tag I'm missing?
Here is my tag on index.html:
<A HREF="showroom.html" target="main"><IMG NAME="front2" SRC="front_2x1.jpg" WIDTH="155" HEIGHT="43" BORDER="0"></A>
What I need is:
From index.html, click on the Showroom link, have index2.html pull up with showroom.html in its respective iframe. I already have the iframe working in index2.html, but am having problems linking it from the NON-iframed page (index.html).
I understand the iframe tag above, but where do I put it, in the case I just described?
SAMPLE LINK ON index.html
<a href="index2.html?showroom.html>Showroom</a>
SCRIPT IN THE <HEAD> OF index2.html
<script type=text/javascript>
origURL = parent.document.URL
iframeURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)
</script>
IFRAME CODE IN THE <BODY> OF index2.html
document.write("<iframe src=\"' + iframeURL + '\" name=\"myiframe\" height=\"200\" width=\"300\"></iframe>")
Just add in your iframe attributes, but use a backslash [\] before every quotation mark. That's called "escaping" -- so the script knows you really mean "write in a quotation mark here" instead of "end the document.write() here".
Your links that are already ON index2.html just need to use the target attribute:
LINK IN THE BODY OF index2.html
<a href="showroom.html" target="myiframe">Showroom</a>
-- Now that you have an answer, can I talk you out of that kind of design? For instance, what happens if someone comes to the iframed page directly, instead of loaded in the iframe on its parent page - called an "orphaned" page? How are people going to bookmark specific iframed content if they want to? How will your visitors see WHICH link they just loaded (that's called a location cue)?
There are many complications and drawbacks to this kind of interface.
I've tested over and over and found that I almost always get better results by avoiding both of them - and still I have a couple pages with big fat framesets because they really are a good tool for the particular job I need to get done. So I completely understand.