Calling onunload in frameset

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Poulos

    Calling onunload in frameset

    In a frameset I have this:

    window.onload = function() {
    frames[1].onunload = function() {
    alert('I'm going now');
    }
    }

    when frames[1] unloads I'm expecting the alert to be called but it never
    does. If, instead, I put this into frames[1] it does call the alert:

    window.onunload = function() {
    alert('I'm also going now');
    }

    How can I get it to work from the frameset?

    Andrew Poulos
  • Csaba2000

    #2
    Re: Calling onunload in frameset

    As I understand your question, your example code is saying, put an onload
    handler on my frame as I'm [= the frameset] unloading myself. But by then
    I'd expect my frame to already be gone. To double check this, also put
    an alert before the frames[1].onunload = function() ... statement.

    Csaba Gabor from Vienna

    "Andrew Poulos" <ap_prog@hotmai l.com> wrote in message news:4241552e$0 $10167$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...[color=blue]
    > In a frameset I have this:
    >
    > window.onload = function() {
    > frames[1].onunload = function() {
    > alert('I'm going now');
    > }
    > }
    >
    > when frames[1] unloads I'm expecting the alert to be called but it never
    > does. If, instead, I put this into frames[1] it does call the alert:
    >
    > window.onunload = function() {
    > alert('I'm also going now');
    > }
    >
    > How can I get it to work from the frameset?
    >
    > Andrew Poulos[/color]

    Comment

    • Andrew Poulos

      #3
      Re: Calling onunload in frameset

      Csaba2000 wrote:
      [color=blue]
      > As I understand your question, your example code is saying, put an onload
      > handler on my frame as I'm [= the frameset] unloading myself. But by then
      > I'd expect my frame to already be gone. To double check this, also put
      > an alert before the frames[1].onunload = function() ... statement.
      >
      > Csaba Gabor from Vienna
      >
      > "Andrew Poulos" <ap_prog@hotmai l.com> wrote in message news:4241552e$0 $10167$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...
      >[color=green]
      >>In a frameset I have this:
      >>
      >>window.onlo ad = function() {
      >> frames[1].onunload = function() {
      >> alert('I'm going now');
      >> }
      >>}
      >>
      >>when frames[1] unloads I'm expecting the alert to be called but it never
      >>does. If, instead, I put this into frames[1] it does call the alert:
      >>
      >>window.onunlo ad = function() {
      >> alert('I'm also going now');
      >>}
      >>
      >>How can I get it to work from the frameset?
      >>
      >>Andrew Poulos[/color]
      >
      >[/color]
      I think I didn't state my problem unambiguously. Let me try again:

      Without putting any script into each frame how can a frameset detect
      events, such as onload and onunload, from each frame (as opposed to the
      entire frameset)?

      Andrew Poulos

      Comment

      • Csaba2000

        #4
        Re: Calling onunload in frameset

        I would try (not that I have, mind you):
        Put into the <head> section of the frameset page:
        <script type='text/javascript'>
        function myFunc() { alert("Here I am"); }
        top.onload = top.setTimeout( function() {
        top.frames[1].onunload = top.myFunc; }, 100)
        </script>

        the setTimeout business is because it may be that the frameset's onload
        fires when the page is read in and not after all the frames have loaded.
        If you determine which it is, it would be good if you would let the group
        know - and perhaps you can relax part of the above code (if it works
        at all, that is).

        Also, when you are doing anything with functions across frames it is a
        good idea to fully qualify them (ie, appropriateWind ow.functionName )

        Csaba

        "Andrew Poulos" <ap_prog@hotmai l.com> wrote in message news:4242a8d7$0 $893$5a62ac22@p er-qv1-newsreader-01.iinet.net.au ...[color=blue]
        > I think I didn't state my problem unambiguously. Let me try again:
        >
        > Without putting any script into each frame how can a frameset detect
        > events, such as onload and onunload, from each frame (as opposed to the
        > entire frameset)?
        >
        > Andrew Poulos[/color]

        Comment

        Working...