0

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.

3
  • 1
    Are you sure that the first page is loaded by the time the second page calls the function? Commented Oct 15, 2009 at 22:27
  • Yes, I've tried with HTML and it works fine. Commented Oct 15, 2009 at 22:29
  • You tried in HTML with the inline script or the script is also loaded via another file? Try to construct your HTML version as close as possible to the ASPX ones. Compare with the rendered ASPX codes too. Commented Oct 16, 2009 at 0:28

2 Answers 2

1

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');
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.