PDA

View Full Version : iframe question


MenionLeah
01-17-2006, 11:57 AM
Hi everyone,

I'm planning on using an iframe for some content on my site.

I'd like to be able to click on a link and have the new content appear in that iframe.

I can't figure out how to do this. I can set up regular links easily with dreamweaver, but i could use some help with this.

And advice would be appreciated.

Thanks.

davidj
01-17-2006, 01:16 PM
use javascript to navigate your pages.

if you have your links in the main page then use this example...
NOTE: iframe1 is the name/id of your iframe

function nav(p){

var ph = p;

switch(ph){

case 'p1': window.frames['iframe1'].location.href=page1.htm; break;
case 'p2': window.frames['iframe1'].location.href=page2.htm; break;
case 'p3': window.frames['iframe1'].location.href=page3.htm; break;

}
}
your links example

<a href="#" onClick="nav('p1')">link to page 1</a>
<a href="#" onClick="nav('p2')">link to page 2</a>
<a href="#" onClick="nav('p3')">link to page 3</a>

not sure if you need to declare your vars in the function so the switch works...
var ph = p;
but i have in this example and it should still work

where i have ...
onClick="nav('p2')">
in the example. I am passing an argument p1,p2,p3 to tell the function where to go


hope this makes sense

domedia
01-17-2006, 01:30 PM
I'm planning on using an iframe for some content on my site.
Don't.
It's an archaic technology, full of usability problems, and actually looks kinda amateurish (you find this mostly on kids websites/geocities).

Try the normal approach, create standalone pages for you content. If you are specifically looking for the scroll effect, use the CSS propert overflow instead:
http://www.dreamweaverclub.com/css-scroller.php ('http://www.dreamweaverclub.com/css-scroller.php')

Creative Insanity
01-17-2006, 07:21 PM
But if you still want to there is an easy way to do it.
Name your iframe, let's just say for this your iframe is called content.
Just make the target of the link go to content and walla.