how to sniff the requested URL

E

Evertjan.

Dica wrote on 24 mrt 2005 in comp.lang.javascript:
i need to add a function to body's onUnload to see which URL has been
requested. if it isn't the same as the current page, i want to ask the
user if they would like to save their changes first. i can use
location.href to get the current page, but is it possible to determine
what the requested URL is prior to unloading the page?

The next page is not accessible to any unload routine.

Wouldn't you think that would be a serious security risk?
 
D

Dica

i need to add a function to body's onUnload to see which URL has been
requested. if it isn't the same as the current page, i want to ask the user
if they would like to save their changes first. i can use location.href to
get the current page, but is it possible to determine what the requested URL
is prior to unloading the page?

tks
 
M

Martin Honnen

Dica said:
i need to add a function to body's onUnload to see which URL has been
requested. if it isn't the same as the current page, i want to ask the user
if they would like to save their changes first. i can use location.href to
get the current page, but is it possible to determine what the requested URL
is prior to unloading the page?

There is no general way to know that, certainly if the browser user
types a new URL in the address bar then script doesn't know the new URL.
If you have links in your document you can however use a document wide
onclick handler and check whether a link was clicked, what href it has.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top