var url = window.location.href; //獲取當前窗口的Url; 結果:http://localhost:61768/Home/Index?id=2&age=18
var host = window.location.host; //獲取當前窗口的主機名; 結果:localhost:61768
var port = window.location.port; //獲取當前窗口的端口; 結果:61768
var pathname = window.location.pathname; //獲取當前窗口的路徑 ; 結果:/Home/Index
var URL = document.URL; //獲取當前文檔的Url;結果:http://localhost:61768/Home/Index?id=2&age=18
var search = window.location.search; //獲取參數;結果:?id=2&age=18
var protocol = window.location.protocol; //獲的是當前地址的協議 結果:http: