Results 1 to 9 of 9

Thread: How do you close an IFRAME window?

  1. #1
    Join Date
    Oct 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do you close an IFRAME window?

    I have an HTML file that opens a DHTML Window ("iframe" content type). The IFRAME has an HTML file with a form in it. After I press OK in the form, I would like to close the DHTML window. But the file in the IFRAME has no knowledge of the dhtmlwindow object in the first file. Ideas? (putting the form code in a "div" content type DHTML Window instead of a "iframe" isn't an option)

    Thanks in advance.

  2. #2
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Try
    Code:
    var ifr = document.getElementById("theIframe");
    ifr.parentNode.removeChild(ifr);
    Trinithis

  3. #3
    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, as I read this, you want to close the iframe from the child page, provided that both the top page and the page in the iframe are on the same domain:

    Code:
    var ifr = parent.document.getElementById("theIframe");
    ifr.parentNode.removeChild(ifr);
    - John
    ________________________

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

  4. #4
    Join Date
    Oct 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    In the dhtmlwindow.js source code there is no ID set for the IFRAME. So just for the sake of it, I went and added id="theIframe" to the code.

    jscheur1, your example destroys the IFRAME associated with the dhtmlwindow object, but the DHTML window is still there. All nice and white and blank, but still there.

  5. #5
    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

    I've moved this to the DD scripts help section as, you don't really want to know how to close an iframe, although you may or may not want to do that too, just to get the form off of the top page completely.

    You want to know how to close the widget. Using the example of the the Google widget from the demo (once again, provided you are on the same domain):

    Code:
    <a href="#" onClick="parent.googlewin.hide(); return false">Hide/close Window</a>
    - John
    ________________________

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

  6. #6
    Join Date
    Oct 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Never mind, I figured it out. I had the variable that contained the widget handle local in scope. Thanks for the help!

    BTW, I used the DOM thingy to remove the IFRAME too. But I had to modify the dhtmlwindow.js source code to assign an ID tot he IFRAME tag. It'd be nice to see that in the permanent source code.

    Code:
    t.contentarea.innerHTML='<iframe src="" style="margin:0; padding:0; width:100%; height: 100%" id="_iframe-'+t.id+'" name="_iframe-'+t.id+'"></iframe>'

    and then when I closed the IFRAME:

    Code:
    var ifr = parent.document.getElementById("_iframe-mywinid");
    ifr.parentNode.removeChild(ifr);
    Last edited by python1340; 10-08-2007 at 06:49 PM.

  7. #7
    Join Date
    Oct 2007
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Another Close Question

    I am trying to use the window widget to act as a video tooltip popup when user mouses over a button image on my site. The site is: www.copycatdigital.ca/test4.html
    I have set it up so that when you mouse over the button the iframe opens with a video embedded in it. When you mouseout, the iframe disappears as it should, but the video keeps playing (Hidden). Is there a way to stop the video as well as hide the iframe?

    Thanks!
    drmeisner

  8. #8
    Join Date
    Oct 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Pause the video or stop it? To stop the video, you should be able to replace the URL with about:blank like so:

    googlewin.onclose = function() { window.frames["_iframe-googlewin"].location.replace("about:blank"); }

    where "googlewin" is the name of the window you gave in your call to dhtmlwindow.open()

  9. #9
    Join Date
    Oct 2007
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the quick reply. The name of the iframe is homewin, and I want to use onmouseout rather than onclose. Does this make the code different?

    Thanks again,
    drmeisner

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
  •