Results 1 to 4 of 4

Thread: Calling a function on the dhtml window

  1. #1
    Join Date
    Aug 2008
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile Calling a function on the dhtml window

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

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/

    3) Describe problem: How can I get the dhtml window object
    and call a fuction on that page from another window. I am using javascript. For som reason I cannont get the window object to
    call the function on the dhtml page.


    Sincere Thanks,
    houstonrca

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

    Default

    There are a few threads on this already- you may want to do a search. For example, lets say on your main page, you've opened up a DHTML modal window:

    Code:
    <script type="text/javascript">
    var mysurvey=dhtmlmodal.open("surveybox", "iframe", "survey.htm", "Fill out this survey", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal")
    </script>
    Then inside survey.htm, you wish to create a link that resizes the window it's contained in. You would do something like:

    Code:
    <a href="#" onClick="parent.mysurvey.setSize(500, 400); return false">Resize Me</a>
    In other words, the key is to call "parent" in front of the method you wish to run, when that method is being called from the DHTML window itself.
    DD Admin

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

    Default

    Sorry if my explanation was not clear . I want to do the reverse..

    call a function in survey the dhtml window content.. from the main page.


    Thanks

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

    Default

    In that case, try something like:

    Code:
    window.frames["_iframe-surveybox"].somefunction()
    to call somefunction() inside the page contained within the DHTML Window, where "surveybox" is the ID of the DHTML window when you called dhtmlwindow.open(), for example:
    Code:
    <script type="text/javascript">
    var mysurvey=dhtmlmodal.open("surveybox", "iframe", "survey.htm", "Fill out this survey", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal")
    </script>
    DD Admin

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
  •