假设当前页完整地址是:http://localhost:8090/Home/Index?id=2&age=18
//获取当前窗口的Url
var url = window.location.href;
//结果:http://localhost:8090/Home/Index?id=2&age=18
//获取当前窗口的主机名
var host = window.location.host;
//结果:localhost:8090
//获取当前窗口的端口
var port = window.location.port;
//结果:8090
//获取当前窗口的路径
var pathname = window.location.pathname;
//结果:/Home/Index
//获取当前文档的Url
var URL = document.URL;
//结果:http://localhost:8090/Home/Index?id=2&age=18
//获取参数
var search = window.location.search;
//结果:?id=2&age=18