如何使用js 让PC站跳转到手机站对应页面,用下面代码即可一步完成
<script type="text/javascript">
(function () {
var ua = navigator.userAgent.toLowerCase();
var bIsIpad = ua.match(/ipad/i) == "ipad";
var bIsIphoneOs = ua.match(/iphone os/i) == "iphone os";
var bIsAndroid = ua.match(/android/i) == "android";
var bIsWM = ua.match(/windows mobile/i) == "windows mobile";
var host = "http://www.ys720.com";
var pathname = window.location.pathname;
if (bIsIpad || bIsIphoneOs || bIsAndroid || bIsWM) {
window.location.href = host + pathname;
}
})();
</script>