搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

location.assign('') not same as location.assign('/')

  • 5 回覆
  • 1 有這個問題
  • 15 次檢視
  • 最近回覆由 jscher2000

more options

location.assign('/') takes me to home page of site location.assign() does nothing (MS edge goes to home page) Not sure which is right, but would like consistency between browsers, for now using location.assign('/')

所有回覆 (5)

more options

https://developer.mozilla.org/docs/Web/API/Location/assign says if you don't supply a valid URL, the browser will throw a syntax error.

more options

Not sure, one browser says it is OK Firefox says not

more options

I suggest using MDN and the caniuse site for cross-browser compatibility information.

more options

Could you give me specific URL names?

more options

MDN is the site I linked to before, Mozilla Developer Network.

caniuse: https://caniuse.com/