电脑手机自适应

自动判断用户打开的是电脑端还是手机端

$(document).ready(function(e) {
        var oWidth =  document.documentElement.clientWidth  ;
        if(oWidth<800){
            window.location.href="../m/index.php";
            }
});
window.onresize=function(e) {
       var oWidth = document.documentElement.clientWidth  ;
    if(oWidth<800){
        window.location.href="../m/index.php";
        }
};
function uaredirect(murl){
  try {
          if(document.getElementById("bdmark") != null){
              return;
          }
          var urlhash = window.location.hash;
          if (!urlhash.match("fromapp")){
              if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad|x11)/i))) {
                      location.replace(murl);
              }
          }
      } catch(err){}
}
uaredirect("../m/index.php");

猜你喜欢

转载自blog.csdn.net/qq_37957273/article/details/89846279
今日推荐