Results 1 to 3 of 3

Thread: DHTML MODAL - does not close for external sites

  1. #1
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question DHTML MODAL - does not close for external sites

    1) Script Title: DHTML MODAL

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...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>


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

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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:

    Code:
    	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){}

  3. #3
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default That worked

    The change suggested by you worked fine. Thanks a lot.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •