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. javascript - 关于vue-cli每次都要build才能放到线上问题。2. 大兄弟们,你们都用什么框架开发 web app3. javascript - webpack异步加载js问题4. python3.x - python连oanda的模拟交易api获取json问题第五问5. javascript - 怎么获取一个页面中的所数据,然后弄成一个json格式的字符串传给后台6. 多维数组遍历,求大佬解答???7. javascript - swiper2索引的问题8. java - Spring 定时任务如何实现每周一某个时间执行?9. javascript - 移动端 点击弹出遮罩层 加断点调试就行 不加断点就不行10. python方法调用

网公网安备