What strategies are used for webpage-skipping?
- 内容介绍
- 文章标签
- 相关推荐
本文共计106个文字,预计阅读时间需要1分钟。
网页跨PC和移动端跳转;函数判断是否为移动端,默认为PC端。检测移动端功能。
webpage skip between PC to moblie;(function () { var isMobile = false // 默认PC端 function mobile() { try { document.createEvent("TouchEvent") return true } catch (e) { return false } } isMobile = mobile() var str = window.location.href if (isMobile && str.indexOf('m.') === -1) { //移动端的处理逻辑 str = str.replace('', 'm.') window.location.href = str } if (!isMobile && str.indexOf('m.') !== -1) { //PC端的处理逻辑 str = str.replace('m.', '') window.location.href = str } })()
本文共计106个文字,预计阅读时间需要1分钟。
网页跨PC和移动端跳转;函数判断是否为移动端,默认为PC端。检测移动端功能。
webpage skip between PC to moblie;(function () { var isMobile = false // 默认PC端 function mobile() { try { document.createEvent("TouchEvent") return true } catch (e) { return false } } isMobile = mobile() var str = window.location.href if (isMobile && str.indexOf('m.') === -1) { //移动端的处理逻辑 str = str.replace('', 'm.') window.location.href = str } if (!isMobile && str.indexOf('m.') !== -1) { //PC端的处理逻辑 str = str.replace('m.', '') window.location.href = str } })()

