jsp页面部分知识点[一直更]

【1】:除去页面空行

 <%@ page trimDirectiveWhitespaces="true" %>

 

【2】:加标题左侧图标

    <!--  '/image/horse.ico' 为项目中的ico图标路径 -->
     <link rel="shortcut icon" href="<%=path %>/image/horse.ico" type="image/x-icon"/>

  

【3】:js获取当前上网国家/省份/城市

  var country = '';
  var province = '';
  var scity = '';
  $.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function() {
    country = remote_ip_info.country;
    province = remote_ip_info.province;
    city = remote_ip_info.city;
  });

 

 【4】判断设备类型,用于区分PC与移动端

//判断设备类型,用于区分PC与移动端
function getDeviceType() {
    var dtype="00";
    var sUserAgent = navigator.userAgent.toLowerCase();
    var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
    var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
    var bIsMidp = sUserAgent.match(/midp/i) == "midp";
    var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
    var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
    var bIsAndroid = sUserAgent.match(/android/i) == "android";
    var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
    var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
    if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
        dtype="01";//移动
    }
    return dtype;
}

 

posted @ 2017-02-09 13:03  Moka<TI  阅读(267)  评论(0编辑  收藏  举报