18.5.14js

1.<input id="b" onkeyup="document.getElementById('b').value=this.value.replace(/./g,'*');" />  输入密码用星号代替   还是有问题,中文输入法下面回车输入英文在谷歌浏览器中还是没有变化   最好用type="password"  原点代替
2.js检测网络:
<script>
var times = 15*60*1000;
var myTime = setTimeout("Timeout()", times);       
function resetTime() {      
    clearTimeout(myTime);       
    myTime = setTimeout('Timeout()', times);       
}    
  
function Timeout() {       
    //alert("您的登录已超时, 请点确定后重新登录!");       
    document.location.href=proto+"//"+ip+"/cgi-bin/login.html";  
}     
document.documentElement.onkeydown=resetTime;      
//document.doocumentElement.onclick=resetTime;   
setInterval(function(){
    if(window.navigator.onLine==true) { 

   // alert("首次 -- 已连接");

  }else { 

   // alert("首次 -- 未连接");


  }
//clearInterval();
  window.addEventListener("online", online, false);

  window.addEventListener("offline", offline, false);

  function online() {  document.location.href=proto+"//"+ip+"/cgi-bin/login.html";    }

  function offline() {  alert($.i18n.map._nonetwork); clearInterval(); }
},1000);
</script>
3.js比较两个数组是否相等
1.利用toString方法,比较。例如: var a = [1,2,3]; var b = [1,2,3]; alert(a.sort().toString() == b.sort().toString()); 结果为true
2.用 for循环(一个一个比)
for(var i=0;i<a.length;i++){if(a[0]==b[0]){ ......}}















猜你喜欢

转载自blog.csdn.net/wangqingqing_/article/details/80547972
js