Results 1 to 6 of 6

Thread: DHTML Modal window: close window when veil is clicked?

  1. #1
    Join Date
    Mar 2007
    Posts
    32
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default DHTML Modal window: close window when veil is clicked?

    1) Script Title:
    DHTML Modal window v1.01

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

    3) Describe problem:
    I use the Window Widget and Modal features without any problem that I haven't managed to solve myself, but now I thought it would improve my site if I could close the popped up "window" by clicking outside it instead of a close button.

    Easiest way should be to add some onClick on the veil, or so I figured, but I didn't figure out how to actually do it. Atleast not fast enough, so thought I might aswell ask the wise people here.

    Tried to add an onClick to the <div> at the bottom of modal.js , which might very well be the easy way to do it, but I didn't get it right. Most likely some issues with the object, cause I always seem to mess/mix them up.

    So any suggestion is greatly appreciated.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Code:
    onclick="window.close()"
    should work

  3. #3
    Join Date
    Mar 2007
    Posts
    32
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks, but that didn't work. But I guess that "window.close()" actually needs to be something else, like either "this.something.somethingelse.close()" or "document.modalwindowsomething.something.close()".

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    oops sorry,

    Code:
    self.close()
    will close the current window

    window.close() is used for external windows

  5. #5
    Join Date
    Mar 2007
    Posts
    32
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks, but I think you have missunderstood me. (or I'm missunderstanding something you're saying )

    It's not an actual window that I want closed, its the popup window widget that "DHTML Modal Window" creates that I want to be closed when someone clicks outside that "window", which would be on the veil which is behind that "window". Aswell as removing the veil aswell, but the close() function for modal window object handles that.

    So all what I need to do is link that close() function to the <div> object which is created in the 2nd to last line in modal.js.

    Perhaps that is what you are trying to do and I just dont understand it, but changing that line to the following doesnt work.

    Code:
    document.write('<div id="interVeil" onClick=\'self.close()\'></div>')

  6. #6
    Join Date
    Mar 2007
    Posts
    32
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I solved it, but in an ugly way. I did:

    Code:
    document.write('<div id="interVeil" onClick=\'mymodalwindow.hide();\'></div>')
    where "mymodalwindow" is the name of the window I assign when I create it with dhtmlmodal.open.

    But there must be some better way to do this, as this only works on a window I've named to "mymodalwindow", and I would prefer if it actually closed whatever modal window that was open, instead of one named just this way.

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
  •