472,958 Members | 1,994 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Frames, windows, functions & onload

Hi all,

I've been eluded the last couple of *days* on the onload mystery within
the frame and function context.
Problem is as follows:
- frameset with two frames. One called scripts and the other called main
- scripts carries a bunch of js functions rechable via
parent.scripts.functioName()
- Main carries the html page that utilizes some functions

All is well until I start using the onload event.
Situation:
1. Main uses an onclick that calls a startFunction() which loads a page
back into main.
2. Since I want this new page to be loaded *before* I go into the next
function I figured setting parent.main.onload = function2bCalled whilst
going into the startFunction() would do the trick.

Not so!! It sets the parent.main.onload allright but after
parent.main.location.href="newPage.html" it does NOT go into
function2bCalled().

Does anybody have a clue as to what is going on here? I'm nearing my
gaga point.

TIA,
Fermin DCG

Jul 20 '05 #1
3 6754
In addition to this, you could set the src of the main frame in your
frameset to be a blank page (blank.htm, blank.asp or whatever it is you're
doing).

Then from within the script frame onLoad event do something like this

top.mainFrame.document.location.replace "main.htm"

This ensures that your script frame has definitely finished loading before
you try to call anything from within the main frame.

Peter.

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:el**********@hotpop.com...
Da Costa Gomez <dc*@xs4all.nl> writes:
2. Since I want this new page to be loaded *before* I go into the next
function I figured setting parent.main.onload = function2bCalled
whilst going into the startFunction() would do the trick.
Not so!! It sets the parent.main.onload allright but after
parent.main.location.href="newPage.html" it does NOT go into
function2bCalled().


As you explain it, it sounds like you set the window's onload handler
before setting the href. Loading a new page gives a new global
javascript object, i.e., a new window object, so the onload handler is
long gone when the page is loaded.
Does anybody have a clue as to what is going on here? I'm nearing my
gaga point.


You can try this as a test:

parent.frames['main'].foo = 42;
parent.frames['main'].location.href="newPage.html";
alert(parent.frames['main'].foo);

It should turn out to alert "undefined". The same goes for your
onload handler.

I think your best chance is to let "newPage.html" have its own
onload handler, which can then call a function you have set up
in advance. E.g.

parent.frames['script'].callback = function2bCalled;
parent.frames['main'].location.href="newPage.html";

and then "newPage.html"'s onload handler calls

parent.frames['script'].callback();

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #2
Da Costa Gomez <dc*@xs4all.nl> writes:
Strangely enough though the example you gave:
parent.frames['main'].foo = 42;
parent.frames['main'].location.href="newPage.html";
alert(parent.frames['main'].foo);

went along fine, no errors (which surprised me a little bit but then
again, who cares).


Was the "newPage.html" already in the main frame? When I tested it
twice in a row, so the href wasn't really changed, the global object
wasn't reset either.
I tested it in Opear, not sure if IE has subtle differences.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
Lasse Reichstein Nielsen wrote:
Da Costa Gomez <dc*@xs4all.nl> writes:

Strangely enough though the example you gave:
parent.frames['main'].foo = 42;
parent.frames['main'].location.href="newPage.html";
alert(parent.frames['main'].foo);

went along fine, no errors (which surprised me a little bit but then
again, who cares).

Was the "newPage.html" already in the main frame?

Tested it with both there and not there, no problems.
When I tested it twice in a row, so the href wasn't really changed, the global object
wasn't reset either.
I tested it in Opear, not sure if IE has subtle differences.

I basically use Mozilla Firebird (switched away from Opera) and IE (to
test). IE is rather boring when it comes to popping windows though.
Seems to have a diff format from open(url, "title") (which works fine in
Opera as wel as FireBird).

Cheers,
Fermin DCG

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: G-Fit | last post by:
Hello group, I use Forms Authentication in an intranet website. This website has a framed default.aspx page : one left frame for a menu, one right frame for the content. The menu depends on the...
2
by: kyle | last post by:
I'm sure this question has been asked many times, but I cannot find an answer that will help me do what I need to do. I have a site with 2 frames -- 'top' and 'main'. 'top' is a navigation /...
1
by: GEvans | last post by:
Hi, I have a HTML page consisting of two frames, one visible and one hidden. The hidden frame contains javascript variables holding session information. The visible frame contains interactive...
2
by: Andrew Poulos | last post by:
I'm trying to use the graphics library wz_jsgraphics.js from http://www.walterzorn.com (I've tried emailing the author but as yet I've not received a reply). I've loaded the external library...
1
by: Bill H | last post by:
I run a dbms application that interfaces with the web. This module creates a frames page with two frames ('main' and 'mwinfoframe'). All communication with the dbms is routed through the...
3
by: Jim Cobban | last post by:
I have a set of web pages that are organized in pairs. One of each pair contains a graphic and the other is an extended description of the graphic. I am trying to set it up that selecting a single...
3
by: register_allocation | last post by:
I have a frameset where I call a JavaScript function in the onLoad method: .... <frameset cols="..." onLoad="setFn()"> ... <frame name="data_frame" ...> </frameset> In setFn, I am...
6
by: pronerd | last post by:
Hi, I am trying to dynamically set an event handler across frames. I have no problems setting properties across frames doing something like parent.ToolMenuFrame.location.href =...
6
by: August Karlstrom | last post by:
Hi everyone, I have some problems loading a page into a frame from a different frame. In Firefox and Explorer the lower frame displays "Test..." but in some older version of Safari it is left...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.