SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: How to change iframe's content?
-
Dec 11, 2003, 06:46 #1
- Join Date
- Sep 2003
- Location
- Europe/Slovenia
- Posts
- 44
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to change iframe's content?
Hi!
It goes like this...i got a page with menus on top and an iframe in the middle of this page. Now what i want to know is how can i change iframe's content when i click on the menu's hyperlinks. Like when i click the "About" in the menu i want to see about.html in iframe.
I hope you understood what i'm trying to do...
-
Dec 11, 2003, 07:28 #2
Is this what u mean ? . then u could do what has been done in the page mentioned, and have links outside that part, and connect the two pages in that manner..
-ruchirPeace.
-
Dec 11, 2003, 07:47 #3
- Join Date
- Sep 2002
- Location
- Grand Rapids, MI
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you keep the link IDs the same as the page names (minus the extention) then you could use this: DEMO
Code:<html> <head> <title>Change iFrame Contents</title> <script language="JavaScript" type="text/javascript"> <!-- function changeFrame(newPage){ document.getElementById('myframe').src = newPage + ".html"; } //--> </script> </head> <body> <div align="center"> <span id="menu"> <a href="#" id="default" onClick="changeFrame(this.id)">Home</a> <a href="#" id="about" onClick="changeFrame(this.id)">About</a> <a href="#" id="contact" onClick="changeFrame(this.id)">Contact</a> </span> <br><br> <iframe src="default.html" id="myframe"> You can't see iFrames :( </iframe> </div> </body> </html>
AndyFrom the English nation to a US location.
-
Dec 11, 2003, 08:18 #4
This builds on awestmoreland's script, but it's more accessible if Javascript and/or iframes are unavailable.
Code:<html> <head> <title>Change iFrame Contents</title> <script language="JavaScript" type="text/javascript"> <!-- function changeFrame(newPage){ document.getElementById("myframe").src = newPage; } //--> </script> </head> <body> <div align="center"> <span id="menu"> <a href="default.html" id="default" onClick="changeFrame(this.href); return false;">Home</a> <a href="about.html" id="about" onClick="changeFrame(this.href); return false;">About</a> <a href="contact.html" id="contact" onClick="changeFrame(this.href); return false;">Contact</a> </span> <br><br> <iframe src="default.html" id="myframe"> You can't see iFrames :(. Use the links above to get to our pages :). </iframe> </div> </body> </html>
-
Dec 11, 2003, 08:44 #5
- Join Date
- Sep 2002
- Location
- Grand Rapids, MI
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by vgarcia
AndyFrom the English nation to a US location.
-
Dec 12, 2003, 15:59 #6
- Join Date
- Sep 2003
- Location
- Europe/Slovenia
- Posts
- 44
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks a lot for your help guys!
Will try it first thing when i get back home...
Bookmarks