Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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»×ãÖ®´¦µãÆÀÖ¸Õý£¡


Ïà¹ØÎĵµ£º

javascriptÖеÄevalº¯ÊýµÄÓ÷¨(תÌù)

±¾ÎĵÄÁ½¸öÄ¿µÄ£º
£¨1£©½éÉÜjavascriptÖеÄevalº¯ÊýµÄÓ÷¨
£¨2£©ÈçºÎÔÚº¯ÊýÄÚÖ´ÐÐÈ«¾Ö´úÂë
►ÏÈÀ´ËµevalµÄÓ÷¨£¬ÄÚÈݱȽϼòµ¥£¬ÊìϤµÄ¿ÉÒÔÌø¹ý¡£
evalº¯Êý½ÓÊÕÒ»¸ö²ÎÊýs£¬Èç¹ûs²»ÊÇ×Ö·û´®£¬ÔòÖ±½Ó·µ»Øs¡£·ñÔòÖ´ÐÐsÓï¾ä¡£Èç¹ûsÓï¾äÖ´Ðнá¹ûÊÇÒ»¸öÖµ£¬Ôò·µ»Ø´ËÖµ£¬·ñÔò·µ»Øundefined¡£
ÐèÒªÌØ±ð×¢ÒâµÄÊǶÔÏóÉùÃ÷Óï· ......

À뿪»­ÃæÊ±µÄJavaScriptÈ·ÈÏÌáʾ

window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;

onbeforeunload ʼþ²Î¿¼µØÖ·
http://msdn.microsoft.com/en-us/ ......

½éÉÜÔõÑù½â¾öJavaScriptÒ³ÃæË¢ÐÂÓ뵯³ö´°¿ÚµÄÎÊÌâ¡£

¡¡½éÉÜÔõÑù½â¾öJavaScriptÒ³ÃæË¢ÐÂÓ뵯³ö´°¿ÚµÄÎÊÌâ¡£
¡¡¡¡1.ÎÞÌáʾˢÐÂÍøÒ³
¡¡¡¡´ó¼ÒÓÐûÓз¢ÏÖ£¬ÓÐÐ©ÍøÒ³£¬Ë¢ÐµÄʱºò£¬»áµ¯³öÒ»¸öÌáʾ´°¿Ú£¬µã“È·¶¨”²Å»áˢС£
¡¡¡¡¶øÓеÄÒ³Ãæ²»»áÌáʾ£¬²»µ¯³öÌáʾ´°¿Ú£¬Ö±½Ó¾ÍË¢ÐÂÁË.
¡¡¡¡Èç¹ûÒ³ÃæÃ»ÓÐform£¬Ôò²»»áµ¯³öÌáʾ´°¿Ú¡£Èç¹ûÒ³ÃæÓÐform±íµ¥£¬
¡¡¡¡a)< fo ......

JavascriptµÝ¹éÓë¸÷ÖÖÑ­»·Ö´ÐÐЧÂʵıȽÏ

ÒÔÏ·ֱðÊÇÓõݹéºÍÁ½ÖÖÑ­»·¶Ôì³²¨ÄÇÆõÊýÁеļòµ¥ÊµÏÖ¡£(½á¹û½ö¹©²Î¿¼)
µÝ¹éµÄģʽ£º
function Fibonacci(num){
if(num <= 2){
return 1;
}else{
return Fibonacci(num - 1) + Fibonacci(num - 2)
}
}
var counter1 = new Counter();
Fibonacci(30);
counter1.show()
//Firefo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ