View Full Version : Drop Down/Overlapping Content - Target IFRAME at same time?

08-16-2006, 07:13 PM
Script: Drop Down/Overlapping Content Script
Script Location: http://www.dynamicdrive.com/dynamicindex5/overlapcontent.htm

<a href="#" onClick="return overlay (this, 'subcontent2', 'rightbottom');MYIFRAMENAME.location.href='mycontent.html'">Show Slideshow</a><br/>

<!--Do not remove outer most DIV tag with id="subcontent2"-->
<DIV id="subcontent2" style="position:absolute; display:none; border: 9px solid black; background-color: white; width: 505px; height: 505px; padding: 8px">

<iframe src="&nbsp;" frameBorder=0 width=500 height=500 scrolling=no name="MYIFRAMENAME"></iframe><br/>

<div align="right"><a href="#" onClick="overlayclose('subcontent2'); return false; MYIFRAMENAME.location.href='mycontent2.html'">Close Box</a></div>

Problem: I am trying to use the overlapping content script to 1. Open an overlapping div (duh). and 2. As I am opening that overlapping div, combine the OnClick event to load the content of an IFRAME within the same overlapping div. Example listed in Red above.

Everything I've tried isn't working. I can get the syntax correct to where the overlapping div opens but the IFRAME isn't being loaded with the content I've requested. Basically I am trying to piggyback the OnClick command to where I can open the overlapping div and at the same time target the IFRAME within the overlapping div to load the "mycontent.html" page.

The reason why I am trying to do it this way instead of just telling the IFRAME src to show "mycontent.html" is because when I close the overlapping div, the flash content of "mycontent.html" still runs in the background. I want to basically reload the IFRAME everytime I choose to open or close the overlapping div. If it's possible to do this by piggybacking the OnClick event and make it work, is it also possible to do another OnClick event with the "overlayclose" function to change the content of the IFRAME once again to "mycontent2.html" (basically to stop the flash content from running in the background)? Example listed in Green above. Thanks guys for your help.

08-16-2006, 07:45 PM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

08-16-2006, 07:48 PM
Sorry, here is the link to the Drop Down/Overlapping Content script: http://www.dynamicdrive.com/dynamicindex5/overlapcontent.htm

08-18-2006, 10:09 AM
The main reason that you are getting nowhere is that the overlapping content script is written to return and, in most cases in modern browsers, to return false. This both stops further processing of anything included after it in an onclick event as well as (in the case of a false return) preventing the link itself from doing anything. If you want to open up your link to dual purpose you must first remove the return:

<a href="#" onClick="return overlay (this, 'subcontent2', 'rightbottom');">

Just by doing that, you could load into an iframe or whatever by appending to the onclick event*, just as you were trying to do. You could add a true return though, and that should allow you to use the link:

<a href="mycontent.html" onClick="overlay (this, 'subcontent2', 'rightbottom');return true;" target="MYIFRAMENAME">

*If taking that approach though, it is best to append a final return false; to the event, unless you want the link firing in some browsers.