473,417 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,417 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 2735
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 that if the frame is unable to navigate to the...
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 submitted and the target is set to the IFrame. I...
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 the incoming document's BODY tag). Under...
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 "main" The code is below: Thanks in advance...
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 cols="135,*,165"> <frame name="logo" src="some.html"...
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 possible reload main page. How should I do it from...
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: 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 frameB.location.reload() fudge in order to get some...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.