私はドメインの後にURLを抽出しようとしていました。このquestionによれば、window.location.pathname
を呼び出すことが可能ですが、私のURLにはhttp://domain:host/something#random=123
は#
を含むすべてのものを削除します。分割や正規表現よりも優れたものはありますか?コードでJavascriptはURL内の#を無視します
:
window.location.pathname("http://domain:host/something#random=123")
戻り/something
望ましい行動:
window.location.unknownMethodToMe("http://domain:host/something#random=123")
は事前に/something#random=123
感謝を返す必要があります。
https://developer.mozilla.org/en-US/docs/Web/API/Location#Examples – epascarello