Javascript¼òÒ×¼ÆʱÆ÷£¨ÓÃÀ´¼ÇËã´úÂëµÄÖ´ÐÐʱ¼ä£©
×Ô¼ºÐ´µÄÒ»¸ö¼òÒ×¼ÆʱÆ÷£¬ÄܼÇËã´úÂëµÄÖ´ÐÐʱ¼ä£¬»¹¿ÉÒÔÄÃÀ´²âÊÔ´úÂëµÄÖ´ÐÐЧÂÊ¡£
function Counter(){
this.start();
}
Counter.prototype.getTime = function(){
var time = new Date();
return time.getSeconds()*1000+time.getMilliseconds();
}
Counter.prototype.start = function(){
this.counting = true;
this.startTime = this.getTime();
}
Counter.prototype.stop = function(){
if(this.counting == true){
this.counting = false;
this.stopTime = this.getTime();
}
}
Counter.prototype.show = function(){
this.counting==true && this.stop();
this.time = this.stopTime-this.startTime;
document.write('Ö´ÐдúÂ뻨·ÑÁË '+this.time+' ºÁÃë<br>');
this.start();
}
ʹÓÃʾÀýÈçÏ£º
var myCounter = new Counter();
for(var i=0;i<500;i++){
document.write('|');
}
myCounter.show();
var myCounter2 = new Counter();
document.write('<br>');
myCounter2.start(); //ÖØпªÊ¼¼Æʱ
for(var i=0;i<500;i++){
document.write('*');
}
myCounter2.stop(); //Í£Ö¹¼Æʱ
for(var i=0;i<500;i++){
document.write(';');
}
myCounter2.show(); //ÕâÀïÏÔʾµÄʱ¼äÊÇÖ´ÐеÚÒ»´ÎforÑ»·ËùÓõÄʱ¼ä(¾ÍÊÇÊä³öÒ»ÅÅ*µÄÄǸö)
ÔÚ´´½¨¶ÔÏóºó»á×Ô¶¯¿ªÊ¼¼Æʱ¡£
µ÷ÓöÔÏóµÄstart()·½·¨½«ÖØпªÊ¼¼Æʱ¡£
µ÷ÓÃstop()·½·¨»áÍ£Ö¹¼Æʱ¡£
show()·½·¨ÓÃÀ´ÏÔʾ´úÂëÖ´ÐеÄʱ¼ä£¨Èç¹ûµ÷ÓÃshow()·½·¨Ç°Ã»Óе÷Óùýstop()£¬»á×Ô¶¯µ÷ÓÃÒ»´Î£©
¶à¸ö¼Æʱ¶ÔÏóÖ®¼ä»¥²»Ó°Ïì¡£
ÒòΪÎÒ»¹ÊǸö²ËÄñ£¬Ï£Íû´ó¼Ò¶ÔÎҵIJ»×ãÖ®´¦µãÆÀÖ¸Õý£¡
Ïà¹ØÎĵµ£º
ʹÓÃtry{...}catch(){} ·½Ê½£¬Àý×ÓÈçÏ£º
function showAlarm(strObject){
try{
svgElement = document.getElementById(strObject);
svgElement.setAttribute("visibility","visible");
setTimeout("hideAlarm()",3000);//3Ãëºó½áÊø±¨¾¯
}catch(ex){
alert("º¯ÊýshowAlarm()·¢ÉúÒì³££º"+ex.descrip ......
×î½ü̫æ,ûÓÐʱ¼ä×ܽṤ×÷ÄÚÈÝÁË,æÀï͵ÏаÉ,¹²ÏíÏÂÎÒµÄJavaScript MD5 ½Å±¾
var hex_chr = "0123456789abcdef";
function rhex(num)
{
str = "";
for(j = 0; j <= 3; j++)
str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
hex_chr.charAt((num >> (j * 8)) & 0x0F);
re ......
ÃÜÂëÒѾÊÇÎÒÃÇÉú»î¹¤×÷Öбز»¿ÉÉٵŤ¾ß,µ«Ò»¸ö²»°²È«µÄÃÜÂëÓÐÓÖÓпÉÄÜ»á¸øÎÒÃÇÔì³É²»±ØÒªµÄËðʧ¡£×÷ΪÍøÕ¾Éè¼ÆÕß,Èç¹ûÎÒÃÇÔÚÍøÒ³ÖÐÄܶÔÓû§ÊäÈëµÄÃÜÂë½øÐа²È«ÆÀ¹À,²¢ÏÔʾ³öÏàÓ¦µÄÌáʾÐÅÏ¢,ÄÇô¶ÔÓû§ÉèÖÃÒ»¸ö°²È«µÄÃÜÂ뽫Óкܴó°ïÖú¡£Í¬Ê±Ò²Ê¹µÃÍøÕ¾¸ü¾ßÈËÐÔ»¯,¸üÓÐÎüÒýÁ¦.
ʲôÊÇÒ»¸ö°²È«µÄÃÜÂëÄØ ......
YUI Compressor ѹËõ JavaScript µÄÄÚÈÝ°üÀ¨£º
ÒƳý×¢ÊÍ
ÒƳý¶îÍâµÄ¿Õ¸ñ
ϸ΢ÓÅ»¯
±êʶ·ûÌæ»»£¨Identifier Replacement£©
YUI Compressor °üÀ¨ÄÄЩϸ΢ÓÅ»¯ÄØ£¿
object["property"] £¬Èç¹ûÊôÐÔÃûÊǺϷ¨µÄ JavaScript ±êʶ·û£¨×¢£ººÏ·¨µÄ JavaScript ±êʶ·û——ÓÉÒ»¸ö×Öĸ¿ªÍ·£¬ÆäºóÑ¡ÔñÐԵؼÓÉÏÒ»¸ö»òÕ ......
var sDate = new Date(Date.UTC(arys[0], arys[1] - 1, arys[2]));
var eDate = new Date(Date.UTC(arys1[0], arys1[1] - 1, arys1[2]));
......