Alert when leaving site.

T

Targa

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
 
T

Targa

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.
 
R

Randy Webb

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

Yup, that it does.
Any way to use this but only when the user leaves the site/domain?

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".

Welcome.
 
A

Alberto

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
 
R

Randy Webb

Alberto said:
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

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

Alberto

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
 
R

Randy Webb

Alberto said:
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.

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

I didn't. But I definitely know how to come close to accomplishing what
the OP asked for.
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.

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

I didn't rebut you, I made a statement of fact.
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.

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?
goodnight

Goodnight.
 
R

Robert

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


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

Robert
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top