标签 JS 下的文章

$(function () {
    var imgList=document.getElementById('pic_list');
    if(imgList!=null){
        var imgs=imgList.getElementsByTagName('img');
        var w=imgList.offsetWidth;
        for(var i=0;i<imgs.length;i++){
          imgs[i].onload=function(){
              console.info( this.width,this.height )
              if( w < this.width ) this.width=w;
          }
        }
    }
});

//判断是支付宝app的浏览器
 var userAgent = navigator.userAgent.toLowerCase();

    if(userAgent.match(/Alipay/i)=="alipay"){
        return true;
    }else{
        return false;
    }



//判断是微信app的浏览器
function isWechat(){
    var userAgent = navigator.userAgent.toLowerCase();

    if(userAgent.match(/MicroMessenger/i)=="micromessenger") {
        return true;
    } else {
        return false;
    }
}

http://blog.csdn.net/xiejunna/article/details/74989704

var time_range = function (beginTime, endTime, nowTime) {
    var strb = beginTime.split (":");
    if (strb.length != 2) {
        return false;
    }

    var stre = endTime.split (":");
    if (stre.length != 2) {
        return false;
    }

    var strn = nowTime.split (":");
    if (stre.length != 2) {
        return false;
    }
    var b = new Date ();
    var e = new Date ();
    var n = new Date ();

    b.setHours (strb[0]);
    b.setMinutes (strb[1]);
    e.setHours (stre[0]);
    e.setMinutes (stre[1]);
    n.setHours (strn[0]);
    n.setMinutes (strn[1]);

    if (n.getTime () - b.getTime () > 0 && n.getTime () - e.getTime () < 0) {
        return true;
    } else {
        alert ("当前时间是:" + n.getHours () + ":" + n.getMinutes () + ",不在该时间范围内!");
        return false;
    }
}
time_range ("21:30", "23:30", "3:22");

效果

2012091317403446

var time_range = function (beginTime, endTime) {
    var strb = beginTime.split (":");
    if (strb.length != 2) {
        return false;
    }

    var stre = endTime.split (":");
    if (stre.length != 2) {
        return false;
    }

    var b = new Date ();
    var e = new Date ();
    var n = new Date ();

    b.setHours (strb[0]);
    b.setMinutes (strb[1]);
    e.setHours (stre[0]);
    e.setMinutes (stre[1]);

    if (n.getTime () - b.getTime () > 0 && n.getTime () - e.getTime () < 0) {
        return true;
    } else {
        alert ("当前时间是:" + n.getHours () + ":" + n.getMinutes () + ",不在该时间范围内!");
        return false;
    }
}
time_range ("21:30", "23:30");

html 标签内容

<div id="navigation">
  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="about.html">About</a></li>
    <li><a href="photos.html">Photos</a></li>
    <li><a href="live.html">Live</a></li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
</div>

JavaScript 代码

function highlightPage() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("navigation")) return false;
  var nav = document.getElementById("navigation");
  var links = nav.getElementsByTagName("a");
  for (var i=0; i<links.length; i++) {
    var linkurl = links[i].getAttribute("href");
    var currenturl = window.location.href;
    if (currenturl.indexOf(linkurl) != -1) {
      links[i].className = "here";
      var linktext = links[i].lastChild.nodeValue.toLowerCase();
      document.body.setAttribute("id",linktext);
    }
  }
}