Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Why doesn't frameset onload event get called when each of the frames has an onload?

Reply
Thread Tools

Why doesn't frameset onload event get called when each of the frames has an onload?

 
 
adnanx82@gmail.com
Guest
Posts: n/a
 
      05-04-2005
Hi,

I'm having a hard time figuring out why the onload event is not being
called for the frameset window in the following simple example. It is
being called for each of the component frames.

Here's the code:

mainpage.html:

<html>
<head><title>Main page</title></head>
<frameset rows="200,*,*">
<frame src="f1.html">
<frame src="f2.html">
<frame src="f3.html">
</frameset>
</html>
<script src = "common.js"></script>
------------
f1.html:

<html>
<head><title>Frame 1</title></head>
<body bgcolor="#ffcc00">
<center>THIS IS FRAME 1</center>
</body></html>
<script src = "common.js"></script>
------------
f2.html:

<html>
<head><title>Frame 2</title></head>
<body bgcolor="#6666ff">
<h2>This is Frame 2</h2>
</body></html>
<script src = "common.js"></script>
------------
f3.html:

<html>
<head><title>Frame 3</title></head>
<body bgcolor="#00ff66">
<center>..........frame 3</center>
</body></html>
<script src = "common.js"></script>
------------
common.js:

window.onload = on_load;
function on_load()
{
alert("in on load for " + self.document.location);
}

Thanks and appreciate any help,

-Adnan.

 
Reply With Quote
 
 
 
 
adnanx82@gmail.com
Guest
Posts: n/a
 
      05-04-2005
I think I figured out the problem. On a frameset page, you can't have
any other content, like the javascript src tag, and so the onload
method is not associated with the onload event for the frameset page.

 
Reply With Quote
 
 
 
 
kaeli
Guest
Posts: n/a
 
      05-04-2005
In article <(E-Mail Removed) .com>, adnanx82
@gmail.com enlightened us with...
> I think I figured out the problem. On a frameset page, you can't have
> any other content,


Sure you can.
I do.

Your problem is your script, not the frameset. The script is being called
after the page has loaded already, rendering it useless. Put the script
before the body/frameset tag (inside head), not after the end html tag.

--
--
~kaeli~
Murphy's Law #3020: Quality assurance doesn't.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

 
Reply With Quote
 
adnanx82@gmail.com
Guest
Posts: n/a
 
      05-04-2005
Thanks for your reply. Do you know why it works for the frame pages
though? It seems like the onload event is being registered and called
for the frame pages even though the script is at the end, but not for
the frameset page.

Thanks,

-Adnan.

 
Reply With Quote
 
kaeli
Guest
Posts: n/a
 
      05-04-2005
In article <(E-Mail Removed). com>, adnanx82
@gmail.com enlightened us with...
> Thanks for your reply. Do you know why it works for the frame pages
> though? It seems like the onload event is being registered and called
> for the frame pages even though the script is at the end, but not for
> the frameset page.


No, I don't, but I do know putting it in the head of the frameset solved the
problem.
I just tested it.

And you're right: it works fine for the other pages. I have no idea why.

--
--
~kaeli~
He's your God, they're your rules - you burn in Hell.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-15-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Thanks for your reply. Do you know why it works for the frame pages
> though?


Though? Read again: It works for the frameset window as well but you
have positioned it wrong within the source code of its document.

> It seems like the onload event is being registered and called
> for the frame pages even though the script is at the end, but
> not for the frameset page.


Every frame is a implemented as a separate Window object.


PointedEars
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is a button Click event also called when a textbox TextChanged event is called??? S_K ASP .Net 6 11-08-2007 07:44 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
base.OnLoad called, OnLoad not executed Fabio R. ASP .Net 0 03-25-2005 01:21 PM
Frameset, Selected Index, Target Frameset relchatt@comcast.net ASP .Net 0 09-29-2004 09:37 PM
Dynamically changing frameset layout (closing frames, reopening frames, etc) JP Javascript 1 07-07-2003 04:58 PM



Advertisments