<script type="text/javascript">
(function(){
? ? var sUserAgent = navigator.userAgent;
? ? if (sUserAgent.indexOf('Android') > -1 && sUserAgent.indexOf( 'Mobile') > -1 ||. sUserAgent.indexOf('iPod') > ||. sUserAgent.indexOf('Symbian') > -1 ||. sUserAgent.indexOf('IEMobile') > /m/';//如何寫當(dāng)前頁面url代碼
}
else
{
? ? }
})();
</script>
//獲取當(dāng)前窗口的 Urlvar?url?=?window.location.href; //結(jié)果:? 獲取當(dāng)前窗口的主機(jī)名 var?host?=?window.location.host; //結(jié)果: localhost:61768 //獲取當(dāng)前窗口的端口 var?port?=?window.location.port; //結(jié)果:61768 //獲取當(dāng)前窗口的路徑 var?pathname?=?window.location.pathname; //結(jié)果: /Home/Index //獲取當(dāng)前文檔的 Urlvar?URL?=?document.URL; //結(jié)果: http://localhost:61768/Home/Index?id=2&age=18 //獲取參數(shù) var?search?=?window.location.search; //結(jié)果: ?id=2&age=18