admin管理员组文章数量:1426118
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
本文标签: javascriptCan I get an event when the address bar is modifiedStack Overflow
版权声明:本文标题:javascript - Can I get an event when the address bar is modified? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745454081a2659022.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论