移动端跳转代码
- 发表于
- javascript , PHP
PHP版
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php $iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone"); $android = strpos($_SERVER['HTTP_USER_AGENT'],"Android"); $palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS"); $berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry"); $ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod"); if ($iphone || $android || $palmpre || $ipod || $berry == true) { echo "<script>window.location='http://m.site.com'</script>"; } ?> |
JavaScript版
1 2 3 4 5 6 7 |
<script type="text/javascript"> <!-- if (screen.width <= 800) { window.location = "http://m.domain.com"; } //--> </script> |
原文连接:移动端跳转代码
所有媒体,可在保留署名、
原文连接
的情况下转载,若非则不得使用我方内容。