得到客戶端時(shí)間:
<code>
function getNowTime(){
var myDate=new Date();
var year= myDate.getFullYear();
var mouth=myDate.getMonth()+1;
var date=myDate.getDate();
var hours=myDate.getHours();
var minutes= myDate.getMinutes();
var ff=myDate.getMilliseconds();
mouth=mouth<10?"0"+mouth:mouth;
date=date<10?"0"+date:date;
hours=hours<10?"0"+hours:hours;
minutes=minutes<10?"0"+minutes:minutes;
return datetime=year+"-"+mouth+"-"+date+" "+hours+":"+minutes;
}
</code>
頁面中禁用右鍵的兩種方法:
<pre><code>
document.oncontextmenu=new Function("event.returnValue=false;");
</code></pre>
<pre><code>
document.oncontextmenu = function(){return false;};
</code></pre>
** js中過指定的時(shí)間執(zhí)行某方法的兩種方法:**<code><pre>
setInterval(functionName, 1000);//前面方法名履羞,后面多久執(zhí)行一次(單位毫秒)</code></pre><code><pre>setTimeout("functionName()", 100);//前面方法名辟狈,后面多久執(zhí)行一次(單位毫秒)</code></pre>
ENTER鍵做TAB鍵使用:
實(shí)現(xiàn)enter鍵后切換輸入框可以設(shè)置控件onkeydown事件:
<code>function enterToTab(){
//判斷按鍵是否是回車鍵
if(event.keyCode ==13){
event.keyCode=9;//設(shè)置按鍵為Tab鍵钧排,Tab值為9
}
}
document.onkeydown=enterToTab;
</code>