JavaScript正则判断浏览器是否为手机浏览器做跳转代码详解编程语言

<script> 
function uaredirect(murl){ 
    try { 
            if(document.getElementById("bdmark") != null){ 
                return; 
            } 
            var urlhash = window.location.hash; 
            if (!urlhash.match("fromapp")){ 
                if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))) { 
                        location.replace(murl); 
                } 
            } 
        } catch(err){} 
} 
</script> 
<script type="text/javascript">uaredirect("http://www.xxx.com/");</script>

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/8785.html

(0)
上一篇 2021年7月18日 22:20
下一篇 2021年7月18日 22:20

相关推荐

发表回复

登录后才能评论