function uaredirect(murl){ try { if(document.getElementById("bdmark") != null) { return; } var noredirect = document.location.search; if (noredirect.indexOf("no_redirect=true") < 0){ if ((navigator.userAgent.match(/(iPhone|iPod|BlackBerry|Android.*Mobile|webOS|Windows CE|IEMobile|Opera Mini|Opera Mobi|HTC|LG-|LGE|SAMSUNG|Samsung|SEC-SGH|Symbian|Nokia|PlayStation|PLAYSTATION|Nintendo DSi)/i)) ) { location.replace(murl); } } } catch(err){} } 使用方法: <script type="text/javascript">uaredirect("http://3g.ifeng.com");</script>