Is there any event
which is generated when the address bar text is modified by the user? Like, when user tries to execute javascript through address bar.
I have checked all the window
events, none of them relate to address bar.
Update
As per the ments, I have tried window.onhashchange
, but it only fires if the hash changes, not for the actual URL.
The reason I need this to find a way to stop the user from executing javascript from address bar. So, the timer solution won't work either.
Is there any way I can catch the onbeforeunload
and set the location back to the previous one?
Is there any event
which is generated when the address bar text is modified by the user? Like, when user tries to execute javascript through address bar.
I have checked all the window
events, none of them relate to address bar.
Update
As per the ments, I have tried window.onhashchange
, but it only fires if the hash changes, not for the actual URL.
The reason I need this to find a way to stop the user from executing javascript from address bar. So, the timer solution won't work either.
Is there any way I can catch the onbeforeunload
and set the location back to the previous one?
- 1 stackoverflow./questions/1930927/… – Quannt Commented Jan 7, 2013 at 9:43
-
It is not a duplicate, the other question is for
hash
change and it won't work for me. – ATOzTOA Commented Jan 7, 2013 at 12:14
2 Answers
Reset to default 2There is no such event (native I mean)
Here is a subject about how to make an event out of window's location changes (uses setInterval):
http://www.bennadel./blog/1520-Binding-Events-To-Non-DOM-Objects-With-jQuery.htm
If you're using ajax, you might wanna check this out:
http://www.asual./jquery/address/
There is none such trick, but maybe the window.onbeforeunload
can help you. With this you can know at least, when the user leaves your page.
See an example of it here: https://web.archive/web/20211028110528/http://www.4guysfromrolla./demos/OnBeforeUnloadDemo1.htm
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745454082a4628406.html
评论列表(0条)