且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

重定向移动网站

更新时间:2023-02-01 22:51:09

如果使用的是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>