472,333 Members | 1,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

modify frame 'onload' ?

hi,

I encounter troubles with frames :(

witht he folowing script in the _top page

function walk(_frames) {
for(var i=0; i<_frames.length; i++) {
var frame = _frames[i];
alert(frame.name);
walk(frame.frames);
}
}
walk(window.frames);

I can walk thru all the frames and display their name. what I want to
do is to modify their 'onload' script to be notified when the frame
content has changed (no, I can not set onload='...' in the html) but
even if I set onload='top.myproc(...)', this top.myproc is never called
:(

is it possible ?

TIA,
Pierre.

Nov 1 '05 #1
6 2543
pi********@gmail.com wrote:
<snip>
I can walk thru all the frames and display their name. what
I want to do is to modify their 'onload' script to be
notified when the frame content has changed (no, I can not
set onload='...' in the html) but even if I set
onload='top.myproc(...)', this top.myproc is never called :(
Yes, that isn't going to work because the act of loading a page into a
frame re-sets the - onload - property of that frame's window/global
object. So any handlers you may externally assign to the property will
be removed prior to their ever getting a chance to execute.
is it possible ?


Broadly no. However, on recent IE versions and recent Mozilla versions,
and using the - attachEvent - and - addEventListener - methods (as
applicable) rather than assigning directly to the onload property, it is
possible to attach an event handler to an IFRAME element and have that
listener execute each time new contents load into the IFRAME. The IFRAME
element itself is not replaced when its contents change. I have never
tried doing the same with the FRAME elements within a FRAMESET but it is
probably worth a try. The results are certainly _not_ cross browser, and
there is no reason to expect this to work at all (that is; no public
specification implies that it should).

Richard.
Nov 2 '05 #2
> Yes, that isn't going to work because the act of loading a page into a
frame re-sets the - onload - property of that frame's window/global
object. So any handlers you may externally assign to the property will
be removed prior to their ever getting a chance to execute.


what do you mean by "the act of loading a page into a frame re-sets the
- onload - property of that frame's window/global object" ? that it
will be reseted to what is defined to in the html ?

Pierre.

Nov 2 '05 #3
pi********@gmail.com wrote:
Yes, that isn't going to work because the act of loading a page into
a frame re-sets the - onload - property of that frame's window/global
object. So any handlers you may externally assign to the property
will be removed prior to their ever getting a chance to execute.


what do you mean by "the act of loading a page into a frame re-sets
the - onload - property of that frame's window/global object" ? that
it will be reseted to what is defined to in the html ?


Yes, and if the HTML (or a script in (or imported by) the HTML) does not
set an onload handler than any existing handlers will just be
cleared/freed.

Richard.
Nov 2 '05 #4

pi********@gmail.com wrote:
hi,

I encounter troubles with frames :(

witht he folowing script in the _top page

function walk(_frames) {
for(var i=0; i<_frames.length; i++) {
var frame = _frames[i];
alert(frame.name);
walk(frame.frames);
}
}
walk(window.frames);

I can walk thru all the frames and display their name. what I want to
do is to modify their 'onload' script to be notified when the frame
content has changed (no, I can not set onload='...' in the html) but
even if I set onload='top.myproc(...)', this top.myproc is never called
:(

is it possible ?

TIA,
Pierre.


Hi. This is probably wide of the mark, and is again not cross-browser,
but do not IE and Mozilla support an onload event on the FRAME and
IFRAME element itself (as well as the window object)?

E.g. something like this (totally untested, probably wrong):-

function walk(_iframes)
{
for(var i=0; i<_iframes.length; i++)
{
var iframe = _iframes[i];
iframe.onload=....;

walk(iframe.contentWindow.document.getElementsByTa gName("IFRAME"))
}
}
walk(document.getElementsByTagName("IFRAME"));

Julian

Nov 2 '05 #5

Julian Turner wrote:
pi********@gmail.com wrote:

Hi. This is probably wide of the mark, and is again not cross-browser,
but do not IE and Mozilla support an onload event on the FRAME and
IFRAME element itself (as well as the window object)?

Richard Cornford wrote
rather than assigning directly to the onload property, it is
possible to attach an event handler to an IFRAME element and have that
listener execute each time new contents load into the IFRAME. The IFRAME
element itself is not replaced when its contents change.


Sorry, just noticed that you mentioned this. Certainly the FRAME
element supports the onload event in IE.

Julian

Nov 2 '05 #6
maybe IFRAMe would work.. or not. I can not test it as I can not modify
the HTML. the only entry point I have is a script in the _top page.

I tried to assign onunload instead of onload and I correctly get the
corresponding events. so now, i know that the frames can suspected to
be reloaded with a different content (suspected as the user may be
going to somewhere else, not modifying hte frmaes content).

maybe I can use that with some timer to check the potentially new frmae
content and reassign them onunload... duno :-/

in anyway, this will be harder that an onload

Pierre.

Nov 2 '05 #7

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

Similar topics

1
by: Robert Oschler | last post by:
I have an frame in one of my documents (not a frameset document). The top level document has an "onload" handler in the BODY tag. I have found...
2
by: Halldór Ísak Gylfason | last post by:
In my application I have an iframe that is empty (and not visible) initially, however when a user presses a button a form is programmatically...
1
by: TPG | last post by:
I'd like a Javascript function I have written to be invoked whenever *any* new document is been loaded into a particular frame (i.e I don't control...
2
by: RWD | last post by:
I am trying to figure out how to change the target frame in my hyperlink on a DHTML menu. The menu is in one frame and the target frame is called...
5
by: Tim Streater | last post by:
I have this arrangement of frames: <html><head><script type="text/javascript"></script></head> <frameset rows="100,*"> <frameset...
2
by: torext | last post by:
I have 3 frame (not frame set) and I want to forse frame1 (where I define language for user) to be load first, before any other frames. And if...
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 ...
6
by: Richard Maher | last post by:
Hi, Now that I am aware that JS on a page in Frame A can directly call a function on a page in Frame B, I no longer have to continue with my...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

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.