javascript ÔØÈëͼƬºóÖ´ÐÐij²Ù×÷
function EnhancedImage(src,onLoaded){
var self = this;
this.src = src;
this.width = 0;
this.height = 0;
this.onLoaded = onLoaded;
this.loaded = false;
this.image = null;
this.load = function(){
if(this.loaded)
return;
this.image = new Image();
this.image.src = this.src;
function loadImage(){
if(self.width != 0 && self.height != 0){
clearInterval(interval);
self.loaded = true;
self.onLoaded(self);//½«ÊµÀý´«Èë»Øµ÷º¯Êý
}
self.width = self.image.width;//ÊÇnumberÀàÐÍ
self.height = self.image.height;
}
var interval = setInterval(loadImage,100);
}
}
function onImageLoad(image){
document.getElementById('banner').appendChild(image.image);
}
var img = new EnhancedImage("somthing.jpg",onImageLoad);
img.load();
newÒ»¸öImage¶ÔÏó£¬ÉèÖÃÁËsrcÊôÐÔ¹ýºó£¬²»¶ÏµÄ¼ì²éÐèÒªÔØÈëµÄͼƬµÄ¿íºÍ¸ß£¬Èç¹ûÔØÈëͼƬ³É¹¦µÄ»°£¬¿íºÍ¸ß¶¼ÊDz»Îª0µÄÊýÖµ£¬Õâ¸öʱºòÍ£Ö¹Interval £¬²¢ÇÒÖ´ÐÐonLoaded¡£
Ïà¹ØÎĵµ£º
JavaScriptʼþ°ó¶¨µÄ·½·¨ËµÃ÷ ÊÕ²Ø
ʼþʹµÃ¿Í»§¶ËµÄ JavaScript Óлú»á±»¼¤»î£¬²¢µÃÒÔÔËÐС£ÔÚÒ»¸ö Web Ò³Ãæ×°ÔØÖ®ºó£¬ÔËÐнű¾µÄΨһ·½Ê½£¬¾ÍÊÇÏìӦϵͳ»òÕßÓû§µÄ¶¯×÷¡£ËäÈ»´ÓµÚÒ»¸öÖ§³Ö½Å±¾±à³ÌµÄä¯ÀÀÆ÷ÃæÊÀÒÔÀ´£¬¼òµ¥µÄʼþ±»ÊµÏÖΪ JavaScript µÄÒ»²¿·Ö£»µ«ÊÇ´ó¶àÊý×î½ü³öÏÖµÄä¯ÀÀÆ÷¶¼ÊµÏÖÁËǿ׳µÄʼþÄ£ÐÍ£¬Ê¹½Å± ......
Javascript ÔÐͺͼ̳Ð(Prototypes and Inheritance) ÊÕ²Ø
Ç°ÃæÎÒÃÇ¿´µ½ÁËÈçºÎʹÓà constructor À´³õʼ»¯¶ÔÏó¡£Èç¹ûÕâÑù×ö£¬ÄÇôÿһ¸ö´´½¨µÄжÔÏó¶¼»á¶ÔÄÇЩÏàͬµÄÊôÐÔ£¬·½·¨½¨Á¢Ò»¸ö¶ÀÁ¢µÄ¸±±¾¡£¶øÊµ¼ÊÉÏÓиü¼ÓÓÐЧµÄ·½·¨À´Ö¸¶¨·½·¨£¬³£Á¿£¬ÒÔ¼°ÆäËûһЩ¿É±»ËùÓиÃÀàµÄ¶ÔÏó¹²ÏíµÄÊôÐÔ¡£
JavaScript ¶ÔÏó´ÓÒ»¸ö ......
°ÑÒÔǰдµÄBLOGת¹ýÀ´°É£¬Õâ¸öÊǸö²»´íµÄJS¸´ÖƵ½¼ôÇа壬Áô×÷¼ÇºÅÒÔ±¸ºóÓá£
<mce:script type="text/javascript"><!--
copyToClip(cpStr){
if(clipboardData){
clipboardData.setData("Text", cpStr);}
else if (netscape){
netscape.security.PrivilegeManager.enablePrivilege( ......
ÒÔÏÂÄú¿ÉÒÔ¿´µ½ÊÕ¼¯µÄ8¸öʵÓÃµÄ JavaScript ²âÊÔ¼°Ð§Ñ鹤¾ß£¬ËüÃǶ¼¿ÉÒÔÔÚ²»Í¬»·¾³Ï½øÐе¥Ôª²âÊÔ¼°Ð£Ñé²âÊÔÄúµÄ½Å±¾¡£
JSLint
JSLintÊÇ»ùÓÚWebµÄÑéÖ¤JavaScript´íÎó´úÂëµÄ¹¤¾ß¡£ËüÓµÓеŦÄܼ°Ìض¨µÄÉèÖÃÀ´Ê¹ÓÃÄúµÄÐèÇó£¬×Ô¶¨ÒåÄãµÄÑéÖ¤Ëã·¨¡£
JsUnit
JsUnitÊÇÒ»¿îÔÚ¿Í»§¶Ë(ÔÚä¯ÀÀʱ)µÄµ¥Ôª²âÊÔJavaScript¿ò¼Ü¡£¶ÔJa ......
javascriptÖжÔÈÕÆÚÊDZȽÏÈõµÄ£¬ÌرðÊÇÈÕÆÚ¸ñʽ»¯ºÍ´Ó×Ö·ûÖлñÈ¡ÈÕÆÚÕâÁ½¸ö¹¦ÄÜÊÇû
Óеģ¬×Ô¼ºÐ´³ÌÐòµÄʱºò·â×°ÁËÕâЩ¹¦ÄÜ£¬·ÖÏíһϣ¬Ï£Íû¶Ô´ó¼ÒÓÐÓá£ÕâЩÀ©Õ¹ÓÐЩÊÇÍøÉÏһЩÅóÓÑдµÄ£¬¾¹ýÎҵĸÄÔ죬ÓÐЩÊÇÎÒ×Ô¼ºÐ´µÄ¡£
º¯ÊýµÄ¹¦ÄÜ·Ö±ðÊÇ£º
Date.prototype.format =
function(format)£º¸ù¾Ý±í´ïʽ½«ÈÕÆÚ¸ñʽ»¯Îª ......