This article mainly introduces the js judgment page whether to open on the PC or the mobile side. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
The js judgment page is in Whether it is opened on PC or mobile, it will jump to different index.html
window.addEventListener('load', function() { // true为手机,false为pc if (!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) { //跳转到移动端 window.location.href = window.location.href.concat('m/'); } else if (!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) { //跳转至pc端 window.location.href = window.location.href.concat('pc/'); } })
. The above is the entire content of this article. I hope it will be helpful to everyone's study. , please pay attention to the PHP Chinese website for more related content!
Related recommendations:
Detailed explanation of js scope
Analysis of js function declaration and function expression
The above is the detailed content of How to determine whether the page is opened on PC or mobile through js. For more information, please follow other related articles on the PHP Chinese website!