onbeforeunload puzzle ...

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

    #1

    onbeforeunload puzzle ...

    i would like to call a cgi script before closing my page. so i placed the
    following in my index.html code

    ..... onbeforeunload= window.location .href='/bin/exit.cgi'>

    the problem is that it never gets called, but if i did:

    ..... onbeforeunload= window.location .href='/bin/exit.cgi';alert ('EXIT HERE')>

    then it gets called and all is working fine.

    how can i do this without calling alert ?

    thanks,
    Mel


  • Brian Genisio

    #2
    Re: onbeforeunload puzzle ...

    Mel wrote:
    [color=blue]
    > i would like to call a cgi script before closing my page. so i placed the
    > following in my index.html code
    >
    > .... onbeforeunload= window.location .href='/bin/exit.cgi'>
    >
    > the problem is that it never gets called, but if i did:
    >
    > .... onbeforeunload= window.location .href='/bin/exit.cgi';alert ('EXIT HERE')>
    >
    > then it gets called and all is working fine.
    >
    > how can i do this without calling alert ?
    >
    > thanks,
    > Mel
    >
    >[/color]

    You are dealing with some black magic, that is not likely to be the same
    in all browsers...

    Idea:
    Make a small, 1x1 IFRAME, with a form in it. Call the submit() method
    of that IFrame's form.

    Brian

    Comment

    • Mel

      #3
      Re: onbeforeunload puzzle ...

      thanks for your help, i have created a <iframe> like you suggested.
      can you help me with the onbefore part please ?
      how can i call the submit button on the iframe from my
      index.html file ?

      thanks a lot
      Mel

      "Brian Genisio" <BrianGenisio@y ahoo.com> wrote in message
      news:3FFAAF89.9 030309@yahoo.co m...[color=blue]
      > Mel wrote:
      >[color=green]
      > > i would like to call a cgi script before closing my page. so i placed[/color][/color]
      the[color=blue][color=green]
      > > following in my index.html code
      > >
      > > .... onbeforeunload= window.location .href='/bin/exit.cgi'>
      > >
      > > the problem is that it never gets called, but if i did:
      > >
      > > .... onbeforeunload= window.location .href='/bin/exit.cgi';alert ('EXIT[/color][/color]
      HERE')>[color=blue][color=green]
      > >
      > > then it gets called and all is working fine.
      > >
      > > how can i do this without calling alert ?
      > >
      > > thanks,
      > > Mel
      > >
      > >[/color]
      >
      > You are dealing with some black magic, that is not likely to be the same
      > in all browsers...
      >
      > Idea:
      > Make a small, 1x1 IFRAME, with a form in it. Call the submit() method
      > of that IFrame's form.
      >
      > Brian
      >[/color]


      Comment

      • Brian Genisio

        #4
        Re: onbeforeunload puzzle ...

        Mel wrote:
        [color=blue]
        > thanks for your help, i have created a <iframe> like you suggested.
        > can you help me with the onbefore part please ?
        > how can i call the submit button on the iframe from my
        > index.html file ?
        >
        > thanks a lot
        > Mel
        >[/color]

        Well, in your IFRAME, you dont even need to have a submit "button"

        In the IFRAME, do something like:
        <FORM ID=myForm ...>
        <INPUT TYPE=hidden NAME=SOMETHING>
        </FORM>

        In the other page, do this:

        window.frames['myFrame'].document.forms['myForm'].submit()

        Comment

        Working...