简体   繁体   中英

Tracing changes to window.location in JavaScript

I have a webapp which is doing a weird, wrong, unexpected redirection through JavaScript (I checked that by disabling JavaScript in the browser. Redirection doesn't happen). I've also checked all the JavaScript code for window.location being set and put breakpoints on it, but it still didn't tell me who did the redirect.

I don't want to add processing before or after redirections, I need to know which code triggered the redirection so I can disabled it.

There's several methods to do navigation in Javascript. Check

  • window.location or document.location
  • window.navigate (only in some browsers)
  • window.history

See eg https://developer.mozilla.org/en-US/docs/DOM/window.history or https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history on history, and https://developer.mozilla.org/en-US/docs/DOM/window.location on window.location

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM