views:

300

answers:

2

I have 2 pages in a frameset, in the first page i have a Javascript Function, the second is an asp.net form with a button, the thing is that I need to call the Javascript function in the first page when user clicks the button:

I'm trying with:

ClientScript.RegisterStartupScript(this.GetType(), "myScript", "<script language=JavaScript>parent.frames[0].Function('parameter')</script>");

There's an alert('...'); in the function but when I call it I don't see anything, apparently the function isn't executed.

¿How can I call the function? Thanks for the help & advises.

+1  A: 

Try using FireBug (for firefox, or use FireBug Lite for other browsers) to see the actual HTML and script that each frame has.
Once you conclude the code is created correctly in the ASP.net, continue to use FireBug to see where your script code goes wrong using breakpoints.
If you want a quicker idea, try using some testing in the code you put before calling the function, try this:

alert(parent.frames.length);
alert(parent.frames[0].Function);
parent.frames[0].Function('parameter');
Dror
A: 

Thanks very much, Dror, for getting me past a time-consuming hassle!

May I add that it looks like one can use the name of the frame in addition to the index (forgive me, folks, if this is obvious):

parent htm:
        :
    <frameset rows="120,*">
        <frame name="OverviewFrame" id="OverviewFrame" src="eoverview.htm">
        <frame name="LegendFrame" id="LegendFrame" src="">
    </frameset>
    <frameset cols="50%,50%">
        <frame name="ControlsFrame" id="ControlsFrame" src="zoomcontrols.htm">
        <frame name="InsetControlsFrame" id="InsetControlsFrame" src="insetcontrols.htm">
    </frameset>
        :

frame htm (insetcontrols.htm):
    parent.frames['OverviewFrame'].enableSync(false);

(where eoverview.htm contains function enableSync(bool))

tested on FF3.6.3, Chrome 4.1.249.1064, Safari 4.0.5, Opera 9.80, IE 8, IE 8 compatibility mode

miket
Happy it helped you :)
Dror