zoukankan      html  css  js  c++  java
  • JavaScript选择打开手机网站还是电脑网站

    现在手机网站越来越普遍,类似京东、淘宝、新浪等等大家都推出了wap版,一种简单的方法判断,JavaScript选择打开手机网站还是电脑网站,如果是手机网站就让网页跳转到手机网址。如果是电脑网站,打开电脑网站。

    <!DOCTYPE html>
    <head>
    <meta charset=utf-8>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>JavaScript选择打开手机网站还是电脑网站</title>
    <link rel="stylesheet" type="text/css" href="css/base.css" />
    <script type="text/javascript">  
    		if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)){
    		window.location.href='手机网站网址';
    		}else{
    			window.location.href='电脑网站网址';
    	                  }
    </script> 
    </head>
    
    <body>
    </body>
    </html> 
    
  • 相关阅读:
    UVa 1605
    UVa 120
    UVa 10384
    UVa 11694
    UVa 11846
    常用小函数
    【DP】:CF #319 (Div. 2) B. Modulo Sum
    类的无参方法
    类和对象
    七言
  • 原文地址:https://www.cnblogs.com/liubeimeng/p/4255706.html
Copyright © 2011-2022 走看看