Results 1 to 3 of 3

Thread: can't close iframe launched by function

  1. #1
    Join Date
    Jul 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default can't close iframe launched by function

    1) Script Title:
    can't close iframe launched by function

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

    3) Describe problem:

    I want to use the iframe window widget but I'm stuck trying to create a link inside the iframe that closes the dhtml window.


    For my purposes, I need the dhtml window appear only when I click on an icon and not instantly when loading page, so I've used this code on my main file:

    function popup(){
    var googlewin=dhtmlwindow.open("googlebox2", "iframe", "window2.htm", "#1: Google Web site", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")
    }

    With this code, If you close the dhtml with the X button and you want to open it again without reloading the page, you won't get any error.

    In the dhtml window I want to close the dhtml window (after doing other things) clicking on a link, so initially the code in the dhtml window was:

    function hidedhtml(){
    parent.googlewin.hide();
    }

    The problem at this point, is that if you have the dhtml window var inside a function in the main file, the function in the iframe doesn't know the id of the dhtml window so I can't close it.

    Does anybody know what code should I put in the iframe to close the dhtml window in this case?


    Thanks in advance.

    Regards,

    Xavi

  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

    If you put the variable into the global scope, it should all work without additional changes:

    Code:
    var googlewin;
    function popup(){
    googlewin=dhtmlwindow.open("googlebox2", "iframe", "window2.htm", "#1: Google Web site", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")
    }
    - John
    ________________________

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

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

    Default

    yeah! It works. I've found also another thread with a similar answer:

    http://www.dynamicdrive.com/forums/s...ad.php?t=22157

    I've been looking for this the whole day. I think I've to learn some javascript basics before modifying scripts...

    Thank you!

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
  •