location.href = ’/m/’;//如何寫當前頁面url代碼
問題描述
<script type="text/javascript">
(function(){
var sUserAgent = navigator.userAgent;
if (sUserAgent.indexOf('Android') > -1 && sUserAgent.indexOf('Mobile') > -1 || sUserAgent.indexOf('iPhone') > -1 || sUserAgent.indexOf('iPod') > -1 || sUserAgent.indexOf('iPad') > -1 || sUserAgent.indexOf('Symbian') > -1 || sUserAgent.indexOf('IEMobile') > -1)
{
document.write(location.search);
location.href = '/m/';//如何寫當前頁面url代碼
}
else
{
}
})();
</script>
問題解答
回答1://獲取當前窗口的Urlvar url = window.location.href;//結果: 獲取當前窗口的主機名var host = window.location.host;//結果:localhost:61768//獲取當前窗口的端口var port = window.location.port;//結果:61768//獲取當前窗口的路徑var pathname = window.location.pathname;//結果:/Home/Index//獲取當前文檔的Urlvar URL = document.URL;//結果:http://localhost:61768/Home/Index?id=2&age=18//獲取參數var search = window.location.search;//結果:?id=2&age=18
相關文章:
1. windows誤人子弟啊2. php傳對應的id值為什么傳不了啊有木有大神會的看我下方截圖3. 如何用筆記本上的apache做微信開發的服務器4. python - linux 下用wsgifunc 運行web.py該如何修改代碼5. 關于mysql聯合查詢一對多的顯示結果問題6. 實現bing搜索工具urlAPI提交7. MySQL主鍵沖突時的更新操作和替換操作在功能上有什么差別(如圖)8. mysql優化 - MySQL如何為配置表建立索引?9. 冒昧問一下,我這php代碼哪里出錯了???10. 數據庫 - Mysql的存儲過程真的是個坑!求助下面的存儲過程哪里錯啦,實在是找不到哪里的問題了。
