【JS】dedecms网站PC和手机站绑定的js代码
在建站的时候,都会将手机站和PC站绑定在 一起,在SEO搜索引擎优化中,有一定的互补作用。在我的大学里用JS来呈现出这样的结果。
用 js
例如: http://www.college-ing.com/templets/js/pc_mobile.js
在自己网站上创建一个js再调用。把那个地址 改成 自己对应的网站就ok。
function is_mobile() { var regex_match = /(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|jigs browser|hiptop|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220)/i; var u = navigator.userAgent; if (null == u) {return true;} var result = regex_match.exec(u); if (null == result) {return false} else {return true} } if (is_mobile()) {document.location.href= 'http://www.college-ing.com/';} //else{document.location.href= 'http://www.college-ing.com/';}
在首页..里面填入调用代码
声明:本网站为“个人非营利性”网站,仅是博主与热心网友收集整理提供的经验记录和学习内容!本站文章图片来源于网络,如若本站图片侵犯了原著者的合法权益,可联系本站删除。
网站初心:一些棘手的、偏门的问题,能比较方便地在一个网站上查询、解决。如能帮到你的,可以在文章结尾赞赏一下,维持网站日常维护!谢谢