PC页面跳转到手机页面,是用JS还是301? 悬赏5元 已结束
PC端地址是www.xxx.com ,wap端页面是wap.xxx.com。手机端访问PC页面时要跳转到WAP。请问是用什么方式跳转过去对优化更好。同时PC端已经加了mobile-agent标签,wap端也加了canonical标签,还需要加其他标签么,方便百度收录,现在百度移动端和wap端收录情况差距很多,很多都是PC收录wap没收录,或者wap收录pc没收录。
<p>用JS跳转就可以了,很简单 网上很多代码</p><pre><script src=" type="text/javascript"></script><script type="text/javascript">uaredirect("需要跳转的手机网址")</script></pre><p>方法二:</p><p><a href="http://javascript:void(0);" class="show-5118-data" rel="Nofollow" target="_blank"></a></p><pre><span><</span><span>script </span><span>language</span><span>="JavaScript"</span><span>></span><span>
</span><span>function</span><span> mobile_device_detect(url) {
</span><span>var</span><span> thisOS </span><span>=</span><span> </span><span>var</span><span> os </span><span>=</span> <span>new</span><span> Array(</span><span>"</span><span>iPhone</span><span>"</span><span>, </span><span>"</span><span>iPod</span><span>"</span><span>, </span><span>"</span><span>iPad</span><span>"</span><span>, </span><span>"</span><span>android</span><span>"</span><span>, </span><span>"</span><span>Nokia</span><span>"</span><span>, </span><span>"</span><span>SymbianOS</span><span>"</span><span>, </span><span>"</span><span>Symbian</span><span>"</span><span>, </span><span>"</span><span>Windows Phone</span><span>"</span><span>, </span><span>"</span><span>Phone</span><span>"</span><span>, </span><span>"</span><span>linux armv71</span><span>"</span><span>, </span><span>"</span><span>MAUI</span><span>"</span><span>, </span><span>"</span><span>UNTRUSTED/><span>"</span><span>, </span><span>"</span><span>Windows CE</span><span>"</span><span>, </span><span>"</span><span>BlackBerry</span><span>"</span><span>, </span><span>"</span><span>IEMobile</span><span>"</span><span>);
</span><span>for</span><span> (</span><span>var</span><span> i </span><span>=</span> <span>0</span><span>; i </span><span><</span><span> i</span><span>++</span><span>) {
</span><span>if</span><span> ((os[i])) {
</span><span>=</span><span> url;
}
}
</span><span>//</span><span>因为相当部分的手机系统不知道信息,这里是做临时性特殊辨认</span>
<span> </span><span>if</span><span> ((</span><span>'</span><span>iPad</span><span>'</span><span>) </span><span>!=</span> <span>-</span><span>1</span><span>) {
</span><span>=</span><span> url;
}
</span><span>//</span><span>做这一部分是因为Android手机的内核也是Linux</span>
<span> </span><span>//</span><span>但是显示信息不尽相同情况繁多,因此从浏览器下手,即用信息做判断</span>
<span> </span><span>var</span><span> check </span><span>=</span><span> </span><span>if</span><span> ((</span><span>/</span><span>linux</span><span>/</span><span>i)) {
</span><span>//</span><span>X11是UC浏览器的平台 ,如果有其他特殊浏览器也可以附加上条件</span>
<span> </span><span>if</span><span> ((</span><span>/</span><span>mobile</span><span>/</span><span>i) </span><span>||</span><span> (</span><span>/</span><span>X11</span><span>/</span><span>i)) {
</span><span>=</span><span> url;
}
}
</span><span>//</span><span>类in_array函数</span>
<span> </span><span>=</span> <span>function</span><span>(e) {
</span><span>for</span><span> (i </span><span>=</span> <span>0</span><span>; i </span><span><</span> <span>this</span><span>.length; i</span><span>++</span><span>) {
</span><span>if</span><span> (</span><span>this</span><span>[i] </span><span>==</span><span> e) </span><span>return</span> <span>true</span><span>;
}
</span><span>return</span> <span>false</span><span>;
}
}
mobile_device_detect(</span><span>"</span><span>需要跳转的手机网址</span><span>"</span><span>);
</span><span></</span><span>script</span><span>></span></pre>
学习一下~
用301或者做主题自适应