checking for back button in JS- what text to search for?

B

bbcrock

I want to check to see if the user uses the back button to exit our
site. I want to stop running certain functions if they leave our site
via a back button.

I am a real newbie for JS and have a limited knowledge or Regular
Expressions.

my code to check for the urls is:
var test_url=/(www.url1.com)|(www.url2.com)|(history.go)/i;

where history.go is my best assumption of code that would identify the
url the browser sees. Doesn't work though. I RTFM'd, I checked
google, I'm not getting this to work.

can anyone post a response here?

thanks!

Don
 
R

Randy Webb

I want to check to see if the user uses the back button to exit our
site. I want to stop running certain functions if they leave our site
via a back button.

Give up. You will fail in the end.
I am a real newbie for JS and have a limited knowledge or Regular
Expressions.

my code to check for the urls is:
var test_url=/(www.url1.com)|(www.url2.com)|(history.go)/i;

where history.go is my best assumption of code that would identify the
url the browser sees. Doesn't work though. I RTFM'd, I checked
google, I'm not getting this to work.

You have no way of knowing how I left your site, only that I left it.
And that I left it is not even true. If I open your site, navigate 3
pages deep, bookmark the page, go back to the homepage and hit the
bookmark, I will "stay on your site" but the home page has no way of
knowing that.
can anyone post a response here?

Where else would it be posted?

Welcome
 
S

Spats30

They're all correct. There is no method in JavaScript to determine
which browser application buttons have been pressed.
 

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
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top