Forum Moderators: open

Message Too Old, No Replies

Opening links into layers

         

TomJS

5:53 am on Mar 21, 2004 (gmt 0)

10+ Year Member



Hi I was wondering how to make a link write something into a layer and how to make a link open an html document in a layer. For example a link called Click Here when clikced on would either open this.htm in a layer called layer1 or write something (like document.write) in layer1. Could somebody give me the script plz?
Oh and by layer I mean like the html tag <div>

Rambo Tribble

1:44 pm on Mar 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, you can't open into a div without eliminating your current document. You can open into an iframe and the easy way to do it is just give your iframe a name and make it the target of your link.

TomJS

2:52 pm on Mar 21, 2004 (gmt 0)

10+ Year Member



what's an iframe? can you give me an example plz? do they work like layers?

Rambo Tribble

3:24 pm on Mar 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, no time this morning, but I think you need to pick up a reference on HTML. It will explain iframes and their usage. Briefly, iframes allow you to place the content of another URL in the body of a page. The iframe (independent frame) can be placed in a div or other block element. The basic tag is <iframe src=""></iframe>.

TomJS

3:47 pm on Mar 21, 2004 (gmt 0)

10+ Year Member



OK I see that now, but how can I change it so that when you "Click Here" the src in the iframe changes?
Say the iframe is named MAIN, would
main.location = "blah.htm"
work?

Rambo Tribble

4:55 pm on Mar 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The easiest is to use the target="main" attribute on the link, otherwise use src not location.

Rambo Tribble

5:14 pm on Mar 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, and if you use src you'll have to give the iframe an id, use getElementById() and so forth. Gotta run, will check back this evening.

TomJS

8:38 pm on Mar 21, 2004 (gmt 0)

10+ Year Member



ok thx, i used main.location and i had no problems but i might use target if it works cuz then i won't have to use script tags.
Thx :)

TomJS

5:13 am on Mar 22, 2004 (gmt 0)

10+ Year Member



well it was going good, until i ran into a snag.
I have links in my index.htm page that change the location of an iframe named "nav" and that works.
I want links in the "nav" iframe to cahnge the location of an iframe in the index but that doesn't work the way I tried, can anybody help me out?

TomJS

5:17 am on Mar 22, 2004 (gmt 0)

10+ Year Member



Nevermind I looked through old posts and fixed it