由于AngularJs
有一个指令onLocationChange()
和C#
具有onActionExecute()
,因此在Javascript中是否有类似这样的事件在整个网站中的任何动作之前执行。
from your question it seems like you want to observe user navigation ie: when ever address bar location gets changed.
You can use an older method detecting whenever page gets refresh
window.addEventListener('beforeunload', function (e) {
// perform something here
}, false);
for SPAs (Single page applications you can use hashchange
//detecting hashchange
window.onhashchange = function() {
//code
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.