locationオブジェクト

[window.]location.プロパティで、現在表示しているページの
各種URL情報を引き出すことができる([window.]は省略可。
現在のウィンドウに別のページを表示するなら、
スクリプトで[window.]location = "URL"とする。
実行結果


ヘッダ部分
なし

ボディ部分 <SCRIPT LANGUAGE="JavaScript"> document.write("[window.]location.protocolは<FONT COLOR='red'> " + location.protocol + "</FONT><BR>") document.write("[window.]location.hostnameは<FONT COLOR='red'> " + location.hostname + "</FONT><BR>") document.write("[window.]location.portは<FONT COLOR='red'> " + location.port + "</FONT><BR>") document.write("[window.]location.hostは<FONT COLOR='red'> " + location.host + "</FONT><BR>") document.write("[window.]location.pathnameは<FONT COLOR='red'> " + location.pathname + "</FONT><BR>") document.write("[window.]location.hashは<FONT COLOR='red'> " + location.hash + "</FONT><BR>") document.write("[window.]location.hrefは<FONT COLOR='red'> " + location.href + "</FONT><BR>") </SCRIPT> <FORM> <INPUT TYPE="button" VALUE="BACK" onClick="location = 'sample0000.html'"> </FORM>