Click to See Complete Forum and Search --> : <frameset ...onload="JS_Function()">
Hi ,
i wrote a JS function which gets run by the top frameset in my index.html entrance site.
Within it, there exist also 3 other framesets and each 2 frames... totally 6 frames.
I will ask, if the JS Function will be executed on each of the 6 frames together?
dragle
10-17-2003, 09:27 AM
The frameset onload should be executed once, after all of its child/nested frames have been loaded.
Cheers
chestertb
10-17-2003, 10:51 AM
Hi Kusi,
If you know what Dragle meant, please ignore this...
But I note that you're a new member and I know from experience how frustrating it can be when if you're on that steep learning curve.
So here's a more simplistic response... it depends what you're trying to do. A function only needs to be loaded once, in your case, in the parent frame.
When the parent frame executes the onload statement, it will call that function just once, as though it was a stand-alone page. It will not call the function as each child frame loads because effectively, you're opening windows within a window, and each is isolated from its parent. If the function you're calling has to do something within each of the frame sets, then as Dragle rightly suggests, run it after the other frames have loaded.
However, a function loaded in the parent frame is available to all its children so if you WANT to execute the function in other frames, you can. To call the function, you need to tell the browser where the function is.
If that is the case, you would call top.JS_function().
Hope that is of some use, and doesn't tell you stuff you already knew.
Cheers
IB
it is that I have created a js fn, and in the top frameset onLoad="this-fn();"> I use.
And, the this-fn, reaches all the frames one by one in its source code, and assigns each of them new location values:
var mainframe = 'controller.jsp?p1=v1';
var topframe = 'controller.jsp?p1=v2';
self.mainFrame.location.replace(mainframe);
self.topFrame.location.replace(topframe);
i mean, onload event handler is executed after body being loaded. But I dont see this. It bypasses normal loding of the page and the js fn onload="" is executed first...
chestertb
10-18-2003, 12:56 AM
I see what you're trying to do. Take the following as a suggestion rather than a solution...
First, because frames seem to sometimes work in unpredictable ways, try
self.mainFrame.location(mainframe);
instead of .location.replace(xx)
If that doesn't work, I'd try moving the function call out of <body onload...> and putting it at the end of the page just before </body>.
Sorry, I can't be more help... perhaps one of the more learneds here might provide a better answer.
Good Luck with it
IB
Hi Chester,
one more question. consider:
within the left-fr I submitted a form, which first changes the top-fr and main-fr location values.
is it the case that after the re-loading of the all the whole frames again; this <frameset onload="this-fn" > thing will run again...
if so I must handle this case also in the this-fn function. At the moment I have some other exceptions so cannot test now.
chestertb
10-23-2003, 02:26 AM
hi kusi,
sorry it's taken so long to get back to this... been out of town and away from a net connection for a few days.
My answer isn't going to help much, because I'm not sure, but I don't think so. If you're just running the function from the parent page that loads the framesets, then it will only run onces. Each frame that loads, or is reloaded isn't going to trigger the initial frameset page...
... unless you're actually reloading the whole page to reset your frame positions.
My suggestion would be to throw an alert() somewhere into the function and see when it actually runs.
Once again, hope that helps.
IB.
thx Chester,
u r right. with the alert("i am here"); i see.
Unless I initialize the /index.html explicitly afterwards, there is no call to the <frameset onload="my-function()">
Regards
Kusi