簡體   English   中英

檢測客戶端與服務器端路由

[英]Detecting client-side vs server-side routing

瀏覽網站時,除了檢查下載的HTML文檔的“網絡”選項卡(在開發工具中)以外,是否有其他方法可以檢測出它是使用客戶端路由還是服務器端路由?

您可以使用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 = '';
   */
});

要檢測對DOM的更改,可以使用MutationObserver 但是我要么使用一個,要么使用另一個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM