'use strict';
{
window.addEventListener('load', function(){
console.log('hash : ' + this.location.hash);
console.log('host : ' + this.location.host);
console.log('hostname : ' + this.location.hostname);
console.log('href : ' + this.location.href);
console.log('origin : ' + this.location.origin);
console.log('pathname : ' + this.location.pathname);
console.log('port : ' + this.location.port);
console.log('protocol : ' + this.location.protocol);
console.log('search : ' + this.location.search);
console.log('searchParams : ' + this.location.searchParams);
console.log('password : ' + this.location.password);
console.log('username : ' + this.location.username);
});
}
参考サイト
URLからドメイン、パス、プロトコル、GETパラメータなど各種情報を取得する
https://gray-code.com/javascript/get-information-from-url/
Location | mdn web docs
https://developer.mozilla.org/ja/docs/Web/API/Location