pc网站和移动端网站url不统一,那这两者之间怎么跳转呢?

没怎么做过移动端网站,(虽然是个基础问题),现在是公司的移动端官网还是做推广时转码的,页面排版非常凌乱,领导让改一下,我自己重新做了个移动端网站,但是url并不是和pc网站一一对应的,(手机端自有一套模板),现在的问题是如何实现用手机访问pc url时,会自动跳转到移动端url,我网上查了一下,说是用什么JS识别UA跳转,但都是很笼统,所以你有什么好的建议和方案麻烦告知下我,解决掉这个烦恼,在此谢过!

慕码人8056858
浏览 918回答 1
1回答

收到一只叮咚

function IsPC() {&nbsp; &nbsp; var userAgentInfo = navigator.userAgent;&nbsp; &nbsp; var Agents = ["Android", "iPhone",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "SymbianOS", "Windows Phone",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "iPad", "iPod"];&nbsp; &nbsp; var flag = true;&nbsp; &nbsp; for (var v = 0; v < Agents.length; v++) {&nbsp; &nbsp; &nbsp; &nbsp; if (userAgentInfo.indexOf(Agents[v]) > 0) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag = false;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp; return flag;}&nbsp;var flag = IsPC(); //true为PC端,false为手机端判断PC端还是移动端,然后跳转对应的 url
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript