By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,624 Members | 1,712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,624 IT Pros & Developers. It's quick & easy.

how to sniff the requested URL

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2

P: n/a


Dica wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.