Javascript 如何压缩/更改手机版本重定向代码?
如何压缩/更改手机版本重定向代码?这使得我的网站速度非常慢,而且在线压缩机无法工作Javascript 如何压缩/更改手机版本重定向代码?,javascript,android,html,iphone,Javascript,Android,Html,Iphone,如何压缩/更改手机版本重定向代码?这使得我的网站速度非常慢,而且在线压缩机无法工作 <script type="text/javascript"> if((navigator.userAgent.indexOf('iPhone')!=-1)||(navigator.userAgent.indexOf('iPod')!=-1)||(navigator.userAgent.indexOf('iPad')!=-1)){document.location="http://mobil
<script type="text/javascript">
if((navigator.userAgent.indexOf('iPhone')!=-1)||(navigator.userAgent.indexOf('iPod')!=-1)||(navigator.userAgent.indexOf('iPad')!=-1)){document.location="http://mobile.gv.x10.mx/"}
</script>
<script type="text/javascript">
-1!=navigator.userAgent.indexOf("Android")&&(document.location="http://mobile.hj.x10.mx/");
</script>
<script>
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i))) {
location.replace("http://mobile.hj.x10.mx/");
</script>
<script>
if (screen.width <= 850) {
document.location = "http://mobile.hj.x10.mx/";
}
</script>
如果((navigator.userAgent.indexOf('iPhone')!=-1)|(navigator.userAgent.indexOf('iPod')!=-1)|(navigator.userAgent.indexOf('iPad')!=-1)){document.location=”http://mobile.gv.x10.mx/"}
-1!=navigator.userAgent.indexOf(“Android”)&&(document.location=”http://mobile.hj.x10.mx/");
if((navigator.userAgent.match(/iPhone/i))| |(navigator.userAgent.match(/iPad/i))){
位置。替换(“http://mobile.hj.x10.mx/");
如果(screen.width,则将所有移动设备重定向到一个页面:
# Redirect Mobile Devices
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile" [NC]
RewriteRule ^(.*)$ http://mobile.onlythebestoftheweb.x10.mx/ [R=301,L]
或者,您可以将每个移动设备发送到不同的页面:
# Redirect Mobile Devices
RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
RewriteRule ^(.*)$ http://mobile.onlythebestoftheweb.x10.mx/ [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
RewriteRule ^(.*)$ http://mobile.onlythebestoftheweb.x10.mx/ [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^.*Android.*$
RewriteRule ^(.*)$ http://mobile.onlythebestoftheweb.x10.mx/[R=301,L]
为什么不使用htacces呢?我认为用JavaScript处理这个问题会更快、更容易(但我可能错了),如果你能使用htacces,我很乐意给出答案。那么,我该怎么做呢?