PDA

View Full Version : Calling a function on the dhtml window



houstonrca
10-20-2010, 02:23 PM
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

ddadmin
10-21-2010, 06:15 AM
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:


<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:


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

houstonrca
10-28-2010, 10:41 PM
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

ddadmin
10-31-2010, 06:36 AM
In that case, try something like:


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:


<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>