问题描述
- 手机访问实现无缝跳转怎么实现?
-
<!---识别手机或电脑的js开始---> <script language="javascript"> (function(){ var res = GetRequest(); var par = res['index']; if(par!='gfan'){ var ua=navigator.userAgent.toLowerCase(); var contains=function (a, b){ if(a.indexOf(b)!=-1){return true;} }; //将下面的http://m.diandazuoye.com改成你的wap手机版地址 var toMobileVertion = function(){ window.location.href = 'http://m.abc.com' } if(contains(ua,"ipad")||(contains(ua,"rv:1.2.3.4"))||(contains(ua,"0.0.0.0"))||(contains(ua,"8.0.552.237"))){return false} if((contains(ua,"android") && contains(ua,"mobile"))||(contains(ua,"android") && contains(ua,"mozilla")) ||(contains(ua,"android") && contains(ua,"opera")) ||contains(ua,"ucweb7")||contains(ua,"iphone")){toMobileVertion();} } })(); function GetRequest() { var url = location.search; //获取url中"/"符后的字串 var theRequest = new Object(); if (url.indexOf("/") != -1) { var str = url.substr(1); strs = str.split("/"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } } return theRequest; } </script> <!---识别手机或电脑的js结束--->
是这样的,上面的代码,能够识别手机访问, 如果手机访问http://www.abc.com,
现在能够实现跳转到m.abc.com现在问题是怎么实现访问http://www.abc.com/cde/123.html 跳转到http://m.abc.com/cde/123.html
解决方案
要无缝跳转,就写在服务器上,写在js上肯定不能无缝
时间: 2024-10-03 14:51:56