【Javascript】URL解析方法

【Javascript】URL解析方法Web開発者の備忘録URLから、ホスト名だけ得たい、パスだけ得たい、パラメータだけ得たい、という場合など
それを簡単に行う方法です。


document.write('window.location'+window.location+'');
document.write('window.location.protocol'+window.location.protocol+'');
document.write('window.location.port'+window.location.port+'');
document.write('window.location.hostname'+window.location.hostname+'');
document.write('window.location.pathname'+window.location.pathname+'');
document.write('window.location.search'+window.location.search+'');
document.write('window.location.hash'+window.location.hash+'');