if (~navigator.userAgent.indexOf('Mobile')) { alert('移动页面');} else { alert('PC页面');}一般判断userAgent中是否包含Mobile字符串即可,但手机浏览器一般可以选择更改UA为PC,所以方法不是100%准确