Results 1 to 9 of 9

Thread: Want to Call OnClose function when Modal Window Closes

  1. #1
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Want to Call OnClose function when Modal Window Closes

    1) Script Title: DHTML Modal

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

    3) Describe problem:
    Hi i have successfully inlcuded the Modal Window script in my page. Now i want to Call The dthmlmodal.onclose function when the User clicks the (X) image button on top right of the modal window. please help me with it. Thanks
    Hitesh
    Last edited by ddadmin; 01-29-2009 at 09:13 PM.

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

    Default

    This was done intentionally to provide a way for users to dismiss the modal window no matter what, such as if an error in the code you've added to the onclose() event causes it to never turn true. Anyhow, to bypass that and have the "x" button also trigger the onclose() event, inside modal.js, try commenting out the below two lines:

    Code:
    	//if (typeof forceclose!="undefined")
    		//t.onclose=function(){return true}
    DD Admin

  3. #3
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi thanks for the reply,

    i tried to comment out the line. but its still not calling the function.

    any ideas?

    thanks
    hitesh

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

    Default

    That should do it actually. Please post a link to the page on your site that contains the problematic script so we can check it out.
    DD Admin

  5. #5
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Its still in test Enviornment. we havent deployed it to production yet

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

    Default

    Upon testing, it seems the onclose() event does fire with the changes I made above, but only if the modal window is an Ajax or Inline based, and not IFRAME window. I'm not quite sure yet why this is so. Before we continue, have you tried the suggestion posted near the end of this thread: http://www.dynamicdrive.com/forums/s...ad.php?t=18354 ?
    DD Admin

  7. #7
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok i tried with it and it worked but other issue got popped.

    Actaully i was closing the window using Window.close function to close the modal window which was working for me (on click of a button on the modal window). But now that event is not firing up i guess.

    Anyways i will also try to find some workaround for me in this case. if you have any other suggessions please do tell me.

    Thanks
    Hitesh

  8. #8
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I had this same problem and I'm happy to hear that other people have worked it out.
    But my problem is that I didn't want to change the code in the delivered library (always a bad idea because when you upgrade you lose your changes)
    So just a tip for anybody else, at startup when you load your page, or when you make your modal window, whenever, do this, and it will override their close function with one that does call onclose when user clicks the X

    dhtmlmodal.close = function(t, forceclose){ //DHTML modal close function
    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
    if (dhtmlwindow.close(t)) //if close() returns true
    this.closeveil();
    };

  9. #9
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default onclose gives an error in IE with pdf front and so doesn't close

    my only problem is that onclose gives an error in IE with pdf front and so doesn't close.

    the previous proposed from Nixonsoe gave me the error :

    "interface is not supported"

    anyone got the answer yet? thanks .

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
  •