Results 1 to 7 of 7

Thread: DHTML Window Widget - Execute JS On Parent Page?

  1. #1
    Join Date
    May 2008
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default DHTML Window Widget - Execute JS On Parent Page?

    1) Script Title:
    DHTML Window Widget

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

    3) Describe problem:

    Is it possible to reach up from the DHTML Window and execute a JS function which is on the parent page?

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

    Default

    This is only applicable if you're using the IFRAME mode. Within the DHTML window page, you can call a function within the parent window using something like:

    Code:
    parent.dothis()
    where dothis() is the function in the parent window. Same idea with variables as well.

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    tiiiim (05-14-2008)

  4. #3
    Join Date
    May 2008
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Ah ... I should have guessed. Thanks!

  5. #4
    Join Date
    Mar 2006
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Can this be done the other way round too? As in, click something on the parent page to change a div or form value on the pop-up? So far I'm not having any luck!!

  6. #5
    Join Date
    May 2008
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Yes ... presuming you have a VAR that is a hanlde to teh window you can use someting like:

    winHandle.contentDoc.getElementById("textbox").value = "Joe";

    This works if the window is a MODAL window ... not sure about the regular one.

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

    Default

    Quote Originally Posted by tiiiim View Post
    Can this be done the other way round too? As in, click something on the parent page to change a div or form value on the pop-up? So far I'm not having any luck!!
    Of course If you're using the IFRAME mode to open a window, for example:

    Code:
    var mywin=dhtmlwindow.open("pagebox", "iframe", "test.htm", "#1: Contact Info", "width=590px,height=350px,resize=1,scrolling=1,center=1")
    The page inside the DHTML window can be accessed using the syntax:

    Code:
    window.frames["_iframe-pagebox"]
    Notice the matching ID attributes in red. So for example:

    Code:
    alert(window.frames["_iframe-pagebox"].document.body.innerHTML)

  8. The Following User Says Thank You to ddadmin For This Useful Post:

    tiiiim (05-14-2008)

  9. #7
    Join Date
    Mar 2006
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Just like to confirm that the

    Code:
    window.frames["_iframe-uniqueID"]
    method works perfectly.

    I did have some reservations as I'd read somewhere else that this wouldn't work in Firefox, but it works fine (I'm use FF3 Beta 5, so not sure about the previous versions...)

    Thanks!!

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
  •