473,544 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.lengt h; i++) {
var frame = _frames[i];
alert(frame.nam e);
walk(frame.fram es);
}
}
walk(window.fra mes);

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.myp roc(...)', this top.myproc is never called
:(

is it possible ?

TIA,
Pierre.

Nov 1 '05 #1
6 2749
pi********@gmai l.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.myp roc(...)', 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 - addEventListene r - 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********@gmai l.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********@gmai l.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.lengt h; i++) {
var frame = _frames[i];
alert(frame.nam e);
walk(frame.fram es);
}
}
walk(window.fra mes);

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.myp roc(...)', 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.leng th; i++)
{
var iframe = _iframes[i];
iframe.onload=. ...;

walk(iframe.con tentWindow.docu ment.getElement sByTagName("IFR AME"))
}
}
walk(document.g etElementsByTag Name("IFRAME")) ;

Julian

Nov 2 '05 #5

Julian Turner wrote:
pi********@gmai l.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
5786
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 document it desires, the top level document "onload" handler does not fire, and therefore important Javascript function I need called is not called. ...
2
18291
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 want to detect when the frame has been loaded with the result of the form submit. Of course I have tried some event handlers like onload, onactivate,...
1
3666
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 MSIE5.5, I've found that the ONLOAD handler attribute of the corresponding frame element is invoked *every* time a new document is loaded into that frame....
2
5286
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 RWD <script type='text/javascript'>
5
1775
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" scrolling="No"> <frame name="title" src="someother.html" scrolling="No"> <frame name="nav" src="yetmore.html" scrolling="No"> </frameset>
2
2837
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 the main aspx page? (ASP.NET) thank you very...
6
9549
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 = 'http://www.blah blah blah.com'; But when I try to set an event handler this way, as shown below, it fails. parent.ToolMenuFrame.window.document.body.onload =...
6
1937
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 code to run in B's context. This is fantastic news, and I'm having a ball! But before running off with all my convert's zeal and converting all my...
0
7452
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7643
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7798
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5956
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5316
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1862
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
688
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.