| | |
Javascript and Iframe Help
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi,
I'm a newbie and trying to use javascript to hide or display different divs within a single IFRAME. I can't seem to get the syntax right... the Iframe, ID "frame", has 5 div's which I want to show depending on what link someone clicks.
here's the js :
and here's the html
and here's frame.html :
Perhaps there's a better way to approach this all together... as I said I'm a newb and any help would be greatly appreciated. Also, how do I close the iframe from within the iframe? I'm not sure that the javascript:Hideframe command is gonna work.
thanks again,
Andrew
I'm a newbie and trying to use javascript to hide or display different divs within a single IFRAME. I can't seem to get the syntax right... the Iframe, ID "frame", has 5 div's which I want to show depending on what link someone clicks.
here's the js :
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type="text/javascript"> <!-- var iframe = document.getElementByID("frame"); var info = iframe.contentDocument function showFrame(page)={ iframe.style.display="block"; if (page = 'weak') { info.getElementByID("weak").style.display = "block"; } else if (page = 'decap') { info.getElementByID("decap").style.display = "block"; } else if (page = 'fire') { info.getElementByID("fire").style.display = "block"; } else if (page = 'peppers') { info.getElementByID("peppers").style.display = "block"; } else if (age = 'bottles') { info.getElementByID("bottles").style.display = "block"; } else { iframe.style.display="hidden";} } //--> </script>
and here's the html
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<body> <div id="container"> <div id="top"> <img src="dhlogo.gif" id="logo"/> <img src="tagline.jpg" id="logo"/> </div> <div id="decap"> <a href="#" onclick="showFrame('weak')"><img src="weaksaucelogo.jpg" width="224" height="144" /></a> <a href="#" onclick="showFrame('decap')"><img src="decapsaicinlogo.jpg" /></a> <a href="#" onclick="showFrame('fire')"><img src="fireandice.jpg" /></a> <p> <a href="#" onclick="showFrame('peppers')"><img src="pepperinfo.jpg" /></a> <a href="#" onclick="showFrame('bottles')"><img src="bottleinfo.jpg" /></a> <img src="shake.jpg" /> </p> <p><a href="mailto:decaphotsauce@gmail.com"><img src="email.jpg"></img></a></p></div> <iframe width="400px" height="500px" scrolling="no" frameborder="0" src="frame.html" id="frame" name="frame" style="left:50%; margin-left: -200px; position:absolute; top:50%; margin-top:-250px; display: none;" ></iframe> </div> </body>
and here's frame.html :
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<body> <a href="javascipt:hideFrame()"><img src="bones2.gif" id="bones" style="border:none"/></a> <div id="info"> <div name="weak" id="weak" style="display: hidden;"><img src="weakinfo.jpg" /></div> <div name="decap" id="decap" style="display: hidden;"><img src="decapsininfo.jpg" /></div> <div name="fire" id="fire" style="display: hidden;"><img src="fireinfo.jpg" /></div> <div name="peppers" id="peppers" style="display: hidden;"><img src="pepperinfotext.jpg" /></div> <div name="bottles" id="bottles" style="display: hidden;"><img src="recycle.jpg" /></div> </div> </body>
Perhaps there's a better way to approach this all together... as I said I'm a newb and any help would be greatly appreciated. Also, how do I close the iframe from within the iframe? I'm not sure that the javascript:Hideframe command is gonna work.
thanks again,
Andrew
•
•
Join Date: Oct 2007
Posts: 37
Reputation:
Solved Threads: 0
0
#2 30 Days Ago
Hi,
I was looking for something like this a few days ago:
take a look at this: link
I hope this helps
By the way, as I searched net, more and more sites didn't recommend using Iframes altogether.
I was looking for something like this a few days ago:
take a look at this: link
I hope this helps

By the way, as I searched net, more and more sites didn't recommend using Iframes altogether.
Last edited by wonderland; 30 Days Ago at 10:23 am.
![]() |
Similar Threads
- Problem with Javascript in Iframe (JavaScript / DHTML / AJAX)
- Javascript iframe or div? (JavaScript / DHTML / AJAX)
- Javascript iFrame problem (having a brain fart) (JavaScript / DHTML / AJAX)
- javascript+iframe (JavaScript / DHTML / AJAX)
- Javascript-populated iframe "ghosting" my footer that is out of the frame (JavaScript / DHTML / AJAX)
- Delay JavaScript execution (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: IE6/IE7 bug in jQuery/CSS
- Next Thread: RSS reader needed
| Thread Tools | Search this Thread |
.net 2.0 adobe adobeacrobat adobereader ajax ajaxexample ajaxhelp api asp asp.net automatically c# cakephp cart checkbox class close codeinjection codes createrange() debugger decimal dependent dom download editor email events explorer firefox flash focus form frameworks getselection google griefers gwt gxt hackers hiddenvalue highlightedword html iframe images input internet java javascript jquery jsf jsfile jsp logfiles loop masterpage math menu microsoft mp4 mysql news paypal pdf php problem programming python regex registrationform runtime safari scale scroll search security session shopping size software synchronous tables text textbox treeview unicode up-to-date validation variables visualization vulnerability w3c web webservice window windowofwords wysiwyg xml zeroday






