[英]Detecting client-side vs server-side routing
浏览网站时,除了检查下载的HTML文档的“网络”选项卡(在开发工具中)以外,是否有其他方法可以检测出它是使用客户端路由还是服务器端路由?
You could use the beforeunload
event to decide what type of routing that is. 您可以使用
beforeunload
事件来确定路由的类型。
window.addEventListener('beforeunload', function (e) {
console.log(e);
// This is usually used to block user navigation, for example, when they have not saved cahnges
/**
* // Cancel the event
* e.preventDefault();
* // Chrome requires returnValue to be set
* e.returnValue = '';
*/
});
To detect changes to DOM, you could use MutationObserver
. 要检测对DOM的更改,可以使用
MutationObserver
。 But I would either useone or the other. 但是我要么使用一个,要么使用另一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.