「JavaScript入門」locationでホストとポートを取得するサンプル

1.ホストの取得
var cftA = location.host;
console.log(cftA);
var cftB = location.hostname;
console.log(cftB);

2.ポートの取得
var cft = location.port;
console.log(cft);

3.パスの取得
var pathname= location.pathname;
console.log(pathname);

4.URLの取得
var cft = location.href;
console.log(cft);

JavaScript

Posted by arkgame