如何将网页跳过功能改写为长尾关键词?
- 内容介绍
- 文章标签
- 相关推荐
本文共计113个文字,预计阅读时间需要1分钟。
网页跳转:在PC端与移动端间切换;函数检测移动端:默认为PC端,通过创建TouchEvent对象判断是否为移动设备,变量isMobile存储检测结果。字符串str存储当前页面URL。
;(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 } })()
本文共计113个文字,预计阅读时间需要1分钟。
网页跳转:在PC端与移动端间切换;函数检测移动端:默认为PC端,通过创建TouchEvent对象判断是否为移动设备,变量isMobile存储检测结果。字符串str存储当前页面URL。
;(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 } })()

