Results 1 to 2 of 2

Thread: No closing the wondows

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

    Default No closing the wondows

    I am trying to open modal using

    I got code fom
    http://www.dynamicdrive.com/dynamici...dhtmlmodal.htm

    Code:
    var test123=dhtmlmodal.open("agreebox", "iframe", "location.do?method=selectlocation&readPreview=3", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0");
    
    test123.onclose=function(){
    // need to do some operation
    }
    }
    and popup jsp page on click of one button trying to close the popup like
    parent.test123.hide();

    but in popup window it is saying test123 is undefind.

    Please help me on this.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Your code snippet has an extra closing brace:

    Code:
    var test123=dhtmlmodal.open("agreebox", "iframe", "location.do?method=selectlocation&readPreview=3", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0");
    
    test123.onclose=function(){
    // need to do some operation
    }
    }
    This implies that it's part of a function, perhaps even an onload function.

    In any case, if that brace were there without its being part of a function, it would cause a fatal scripting error and the modal wouldn't even load.

    So that means that you are declaring test123 in a limited scope, one not available by doing parent.anything from the iframe.

    You need to get it out of that function, or declare the variable globally. The latter would be easier:

    Code:
    window.test123=dhtmlmodal.open("agreebox", "iframe", "location.do?method=selectlocation&readPreview=3", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0");
    
    test123.onclose=function(){
    // need to do some operation
    }
    }
    If you want more help:

    Please post a link to a page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •