リファラーを除いて、document.location.pathnameであるjavascriptで同じ機能をどのように実行できますか?したがって、document.referrer.pathnameのようなものですか?
ありがとう。
リファラーを除いて、document.location.pathnameであるjavascriptで同じ機能をどのように実行できますか?したがって、document.referrer.pathnameのようなものですか?
ありがとう。
いいえ、必要な部分を手動で抽出することしかできません。
document.referrer.replace(/^[^:]+:\/\/[^/]+/, '').replace(/#.*/, '')
からパス名を抽出し、次のコードでdocument.referrer
解析できますnew URL()
const url = new URL(document.referrer)
url.pathname
必ずIE10以下のURLをポリフィルしてください。https: //polyfill.io/v3/polyfill.js?features=URLで簡単に実行できます。
を使用document.referrer
して、参照ドキュメントのURLを取得できます。それはどういう意味ですか?