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

Discussion in 'Javascript' started by adnanx82@gmail.com, May 4, 2005.

  1. Guest

    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.
     
    , May 4, 2005
    #1
    1. Advertising

  2. Guest

    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.
     
    , May 4, 2005
    #2
    1. Advertising

  3. kaeli Guest

    In article <>, 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
     
    kaeli, May 4, 2005
    #3
  4. Guest

    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.
     
    , May 4, 2005
    #4
  5. kaeli Guest

    In article <>, 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
     
    kaeli, May 4, 2005
    #5
  6. 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
     
    Thomas 'PointedEars' Lahn, May 15, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fabio R.
    Replies:
    0
    Views:
    802
    Fabio R.
    Mar 25, 2005
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,988
    Smokey Grindel
    Dec 2, 2006
  3. S_K
    Replies:
    6
    Views:
    1,187
    Robert Dunlop
    Nov 8, 2007
  4. JP
    Replies:
    1
    Views:
    465
    Martin Honnen
    Jul 7, 2003
  5. mygoogleac
    Replies:
    0
    Views:
    182
    mygoogleac
    Oct 2, 2003
Loading...

Share This Page