Results 1 to 5 of 5

Thread: Window Widget - Closing window from inside window

  1. #1
    Join Date
    Jun 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Window Widget - Closing window from inside window

    1) Script Title: DHTML Window widget (v1.03)

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

    3) Describe problem:

    I am using the script to popup a window pulling the content from an iframe, but I want to put a link inside that iframe that can close that popup window. The script that is provided in the notes tells me how to close the window from the 'opener' using googlewin.hide() but I can't use this in the iframe content itself.

    Can anyone tell me how I close/hide the popup with a link inside the iframe html?

    If I put <a href="#" onClick="googlewin.hide(); return false;">Hide Window</a> I get an error saying googlewin is not defined.

    Thanks

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

    Default

    Try something like:

    Code:
    <a href="#" onClick="parent.googlewin.hide(); return false;">Hide Window</a>
    The code in red is new.

  3. #3
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Hmm... Didn't seem to do it...

    Hi,

    Your solution didn't seem to do it over here... I have a DHTML iframe window called with this link action:
    Code:
    onclick="var winError=dhtmlwindow.open('winError', 'iframe', '_sys/winError.inc.htm', 'Rapporter feil', 'width=300px,height=200px,center=1', '')"
    I've added the following code in the iframe HTML, hoping to close the window:
    Code:
    onclick="parent.winError.hide(); return false;"
    ...But it failed, and returned the following error:
    parent.winError has no properties
    Anybody out there with a solution to this? I simply don't get it

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

    My guess would be, if everything else is right, which it appears to be (except that you should probably return false from the opening onclick event as well), that since onclick events are technically functions and any variables declared in them will only be available to them, you need to get your:

    Code:
    var winError
    into the global scope. There are various ways. I'd recommend doing it like so:

    Code:
    onclick="window.winError=dhtmlwindow.open('winError', 'iframe', '_sys/winError.inc.htm', 'Rapporter feil', 'width=300px,height=200px,center=1', '');return false;"
    Then hiding it like so (from within the iframe):

    Code:
    onclick="parent.window.winError.hide(); return false;"
    There could also be other problems.
    - John
    ________________________

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

  5. #5
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Straight out brilliant, John! That did the trick, thanks a lot

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
  •