重定向移动网站 [英] Redirect Mobile Websites

查看:63
本文介绍了重定向移动网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建该网站的移动版本,但是一件令人困惑的事情正在成为我的障碍.我已经在主要网站上粘贴了一些JavaScript代码,以将移动用户重定向到移动网站,但是它无法正常工作,所以我该怎么办.
请使用示例进行详细说明.

I am creating a mobile version of the site but one confusing thing is becoming a hurdle for me. I have pasted some javascript code on main website to redirect the mobile users to mobile website but its not working properley so what can i do.
Please Details with example.

推荐答案

如果使用的是ASP.NET,则可以在服务器端检测到移动设备.
在CodePlex的开源项目上查看此项目,它支持最大数量的设备.
http://51degrees.codeplex.com/ [ ^ ]
You can detect the mobiles on the server side if you are using ASP.NET.
Have a look at this project on CodePlex its open source and supports maximum devices.
http://51degrees.codeplex.com/[^]


<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "mobile.html";
}
//-->
</script>



"mobile.html"将替换为您的移动版本所在的位置.该技术也可以适用于加载替代样式表.

专门用于iPhone/iPod



"mobile.html" would be replaced with the location of wherever your mobile version resides. This technique could be adapted to load an alternate stylesheet as well.

For iPhones/iPods Specifically

<script language="javascript">
<!--
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
   location.replace("http://url-to-send-them/iphone.html");
}
-->
</script>


这篇关于重定向移动网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆