PDA

View Full Version : DHTML MODAL - does not close for external sites



xanvis
06-05-2008, 06:49 PM
1) Script Title: DHTML MODAL

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/dhtmlmodal.htm


3) Describe problem:
In a modal iframe - if the target is an external site (e.g. google.com) the window does not close in IE when the 'X' button is clicked. In FF it closes alright.

Here is the script ------------>


<script type="text/javascript">
function opengoogle(){ //Define arbitrary function to run desired DHTML Window widget codes
googlewin=dhtmlmodal.open( 'ajaxgooglebox', 'iframe', 'http://google.com', '#3: Ajax Win Title', 'width=650px,height=450px,center=1,resize=1,scrolling=1')
googlewin.onclose=function(){return true} //Run custom code when window is about to be closed
}
</script>
<ul>
<li><b><a href="#" onClick="opengoogle(); return false">Create/ Open Google</a> (in IE, this Ajax demo must be run online!)</b></li>


<-----------------------

ddadmin
06-05-2008, 07:55 PM
Ah this, this happens due to an error when the script tries to access the document contained in the IFRAME. Off site pages are off limits for a local script.

In modal.js, add the below lines in red to the existing one below:


try{
t.contentDoc=(t.contentarea.datatype=="iframe")? window.frames["_iframe-"+t.id].document : t.contentarea //return reference to modal window DIV (or document object in the case of iframe
}
catch(e){}

xanvis
06-06-2008, 02:32 AM
The change suggested by you worked fine. Thanks a lot.