Alert when leaving site.

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

    #1

    Alert when leaving site.

    Ive seen alert scripts triggered by links but I need one that will cover any
    link or pressing the back/forward buttons.

    Any such thing?

    TIA



  • Alberto

    #2
    Re: Alert when leaving site.

    <body onUnload="alert ('bye')">
    Test it on NS7 too, I never tested on it. Doesn't work on NS4.
    ciao
    Alberto





    "Targa" <targa1_removet historeply_@all tel.net> ha scritto nel messaggio
    news:kG8Uc.87$I V3.25@fe39.usen etserver.com...[color=blue]
    > Ive seen alert scripts triggered by links but I need one that will cover[/color]
    any[color=blue]
    > link or pressing the back/forward buttons.
    >
    > Any such thing?
    >
    > TIA
    >
    >
    >[/color]


    Comment

    • Targa

      #3
      Re: Alert when leaving site.

      Thanks but this would cause an alert even when going to pages within the
      site.

      Any way to use this but only when the user leaves the site/domain?

      Thanks.




      "Alberto" <nospam@nospam. nospam> wrote in message
      news:4k9Uc.1129 56$OR2.5890816@ news3.tin.it...[color=blue]
      > <body onUnload="alert ('bye')">
      > Test it on NS7 too, I never tested on it. Doesn't work on NS4.
      > ciao
      > Alberto
      > http://www.unitedscripters.com/
      >
      >
      >
      >
      > "Targa" <targa1_removet historeply_@all tel.net> ha scritto nel messaggio
      > news:kG8Uc.87$I V3.25@fe39.usen etserver.com...[color=green]
      > > Ive seen alert scripts triggered by links but I need one that will cover[/color]
      > any[color=green]
      > > link or pressing the back/forward buttons.
      > >
      > > Any such thing?
      > >
      > > TIA
      > >
      > >
      > >[/color]
      >
      >[/color]



      Comment

      • Randy Webb

        #4
        Re: Alert when leaving site.

        Targa wrote:[color=blue]
        > Thanks but this would cause an alert even when going to pages within the
        > site.[/color]

        Yup, that it does.
        [color=blue]
        > Any way to use this but only when the user leaves the site/domain?[/color]

        No, not an infallible way. You could set an onclick in each link that
        sets a variable to false, onunload check that variable. If its false, no
        alert. If its true, alert.

        The fallibility of that?

        Lets say I am on page1.html of your site, and I have page31.html saved
        in my Favs and I click on the faves to get straight to page31.html
        instead of having to browse your site. There is *no* way to know I did
        that from the browser/page perspective. Hence the "not infallibly".
        [color=blue]
        > Thanks.[/color]

        Welcome.

        --
        Randy
        comp.lang.javas cript FAQ - http://jibbering.com/faq

        Comment

        • Ian Stirling

          #5
          Re: Alert when leaving site.

          Targa <targa1_removet historeply_@all tel.net> wrote:[color=blue]
          > Ive seen alert scripts triggered by links but I need one that will cover any
          > link or pressing the back/forward buttons.
          >
          > Any such thing?[/color]

          If there was, I'd want it disabled by default in my browser.
          What's the first thing that many sites would do if they could do
          actions on the "back" button.

          Comment

          • Alberto

            #6
            Re: Alert when leaving site.

            you can append a query string to your links except to the front page. Upon
            unload if the query string is not there it fires the alert. But honestly not
            worth the toil lol
            ciao
            Alberto

            "Targa" <targa1_removet historeply_@all tel.net> ha scritto nel messaggio
            news:hNaUc.540$ IV3.382@fe39.us enetserver.com. ..[color=blue]
            > Thanks but this would cause an alert even when going to pages within the
            > site.
            >
            > Any way to use this but only when the user leaves the site/domain?
            >
            > Thanks.
            >
            >
            >
            >
            > "Alberto" <nospam@nospam. nospam> wrote in message
            > news:4k9Uc.1129 56$OR2.5890816@ news3.tin.it...[color=green]
            > > <body onUnload="alert ('bye')">
            > > Test it on NS7 too, I never tested on it. Doesn't work on NS4.
            > > ciao
            > > Alberto
            > > http://www.unitedscripters.com/
            > >
            > >
            > >
            > >
            > > "Targa" <targa1_removet historeply_@all tel.net> ha scritto nel messaggio
            > > news:kG8Uc.87$I V3.25@fe39.usen etserver.com...[color=darkred]
            > > > Ive seen alert scripts triggered by links but I need one that will[/color][/color][/color]
            cover[color=blue][color=green]
            > > any[color=darkred]
            > > > link or pressing the back/forward buttons.
            > > >
            > > > Any such thing?
            > > >
            > > > TIA
            > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >
            >[/color]


            Comment

            • Randy Webb

              #7
              Re: Alert when leaving site.

              Alberto wrote:[color=blue]
              > you can append a query string to your links except to the front page. Upon
              > unload if the query string is not there it fires the alert. But honestly not
              > worth the toil lol[/color]

              Thats not only not worth the toil, it won't work.

              --
              Randy
              comp.lang.javas cript FAQ - http://jibbering.com/faq

              Comment

              • Alberto

                #8
                Re: Alert when leaving site.

                ahhhhhh, a rebuttal....
                Well Randy, I do that on my website, though I don't fire an alert by that
                but I do another thing; guess what: it works.

                If you don't know how to do a thing, don't jump on those who hint they do
                it.
                When I don't understand something, I at most ask cfor clarification, I
                never, never draw a conclusion, especially if it is just to add a stupid
                comment to a person who was trying to provide some help to a THIRD person.

                Never rebuttals, Randy. Never. Didn't mom tell you, after so many years on
                this group?

                N E V E R rebuttals - they cause problems. And as I said, not only it is
                not worth the toil, but if you take the toil, it W_O_R_K_S.

                goodnight


                "Randy Webb" <HikksNotAtHome @aol.com> ha scritto nel messaggio
                news:QNudnfegQ8 LYxrzcRVn-iQ@comcast.com. ..[color=blue]
                > Alberto wrote:[color=green]
                > > you can append a query string to your links except to the front page.[/color][/color]
                Upon[color=blue][color=green]
                > > unload if the query string is not there it fires the alert. But honestly[/color][/color]
                not[color=blue][color=green]
                > > worth the toil lol[/color]
                >
                > Thats not only not worth the toil, it won't work.
                >
                > --
                > Randy
                > comp.lang.javas cript FAQ - http://jibbering.com/faq[/color]


                Comment

                • Randy Webb

                  #9
                  Re: Alert when leaving site.

                  Alberto wrote:[color=blue]
                  > ahhhhhh, a rebuttal....
                  > Well Randy, I do that on my website, though I don't fire an alert by that
                  > but I do another thing; guess what: it works.[/color]

                  I guess it depends on the definition of "works" and what the criteria are.
                  [color=blue]
                  > If you don't know how to do a thing, don't jump on those who hint they do
                  > it.[/color]

                  I didn't. But I definitely know how to come close to accomplishing what
                  the OP asked for.
                  [color=blue]
                  > When I don't understand something, I at most ask cfor clarification, I
                  > never, never draw a conclusion, especially if it is just to add a stupid
                  > comment to a person who was trying to provide some help to a THIRD person.[/color]

                  Nor do I.
                  [color=blue]
                  > Never rebuttals, Randy. Never. Didn't mom tell you, after so many years on
                  > this group?[/color]

                  I didn't rebut you, I made a statement of fact.
                  [color=blue]
                  > N E V E R rebuttals - they cause problems. And as I said, not only it is
                  > not worth the toil, but if you take the toil, it W_O_R_K_S.[/color]

                  I still beg to differ. If you are appending a querystring and check for
                  that querystring, you would have to either check the destination (via
                  onclick), or, check it upon load. Checking it upon load doesn't tell you
                  anything other than where you came from, not where you are going. That
                  leaves checking it when you leave the page. The only way to check it
                  when you leave the page is to have an onclick on each button/link that
                  sets some flag, then check that flag. That still won't tell you the
                  scenario I gave.

                  page2.html has a link to page3.html to page4.html and so on to
                  page15.html. Now, lets say I bookmark page15.html, and open page2.html.

                  You have code in page2.html that attempts to detect the destination when
                  I leave. I open the Favs and click the link to page15.html (or even
                  better example is to go to a different site all together). Now, since
                  page2.html has absolutely *no* way of knowing where I am going, would I
                  get the alert or not? And, should I? Going to page15.html from my Favs,
                  I shouldn't get the alert, but going to any other non-same-site should
                  give the alert. Yet, the document has *no* way of determining that.

                  So again, no, you can *not* tell where I am going when I leave a page
                  (with the above noted exception), only that I left. And that is at it
                  should be. I left, leave me alone, let me surf in peace. To give me an
                  annoying alert when I leave is a sure fire way to make sure a surfer
                  *never* comes back.

                  As for my second argument as it not "working". Disable javascript in
                  your browser, and then please, for the life of me, tell me how you
                  intend to popup, popunder, alert, confirm, prompt or anything else in
                  script?
                  [color=blue]
                  > goodnight[/color]

                  Goodnight.

                  --
                  Randy
                  comp.lang.javas cript FAQ - http://jibbering.com/faq

                  Comment

                  • Robert

                    #10
                    Re: Alert when leaving site.

                    "Targa" <targa1_removet historeply_@all tel.net> wrote in message news:<kG8Uc.87$ IV3.25@fe39.use netserver.com>. ..[color=blue]
                    > Ive seen alert scripts triggered by links but I need one that will cover any
                    > link or pressing the back/forward buttons.
                    >[/color]


                    And most people avoid those sites unless they are giving away something for free.

                    Robert

                    Comment

                    Working...