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

JavaScript Moduleģʽ(ÒëÎÄ)


JavaScript Module Pattern
£¨
JavaScript
Module
ģʽ£© 
À´Ô´£º
1.      
http://yuiblog.com/blog/2007/06/12/module-pattern/
2.      
http://yuiblog.com/blog/2006/06/01/global-domination/
 
È«¾Ö±äÁ¿ÊÇÓкܴóΣº¦µÄ¡£ÔÚ
YUI
ÖУ¬ÎÒÃǽö¶¨ÒåÁËÁ½¸öÈ«¾Ö±äÁ¿£º
YAHOO
ºÍ
YAHOO_config
¡£
YUI
ÖнöʹÓÃ
YAHOO
¶ÔÏó²ã´ÎµÄ³ÉÔ±»òÕß¿Éͨ¹ý³ÉÔ±·ÃÎʵıäÁ¿¡£ÎÒÃǽ¨ÒéÔÚÄã×Ô¼ºµÄÓ¦ÓÃÖÐÒ²×ñѭͬÑùµÄ¹æÔò¡£
Douglas
Crockford
ÒѾ­½Ì¸øÎÒÃÇÒ»¸öÓÐÓõĵ¥ÀýģʽÀ´ÊµÏִ˹æÔò£¬ÎÒÏëÈç¹ûÄãÊÇ»ùÓÚ
YUI
½øÐй¹½¨£¬ÄÇÄãÒ»¶¨¶Ô´ËºÜ¸ÐÐËȤ¡£
Douglas
³Æ֮Ϊ
”module pattern”
¡£ÏÂÃæÊÇËüµÄ¾ßÌ幤×÷·½Ê½£º
´´½¨Ò»¸ö
namespace
¶ÔÏó
Èç¹ûÄãÕýʹÓÃ
YUI
£¬Äã¿ÉÒÔʹÓÃ
YAHOO.namespace()
·½·¨£º
YAHOO.namespace(“myProject”);
Õâ¸öµ÷Óô´½¨ÁËÒ»¸ö¿Õ¶ÔÏó
myProject
£¬²¢Ê¹Æä³ÉΪ
YAHOO
µÄÒ»¸ö³ÉÔ±±äÁ¿£¨Èç¹û
myProject
ÔÚ
YAHOO
ÖÐÒÑ´æÔÚ£¬²¢²»»á¸²¸ÇËü£©¡£ÏÖÔÚÎÒÃÇ¿ÉÒÔ¿ªÊ¼Îª
YAHOO.myProject
Ìí¼Ó³ÉÔ±¡£
½«ÄäÃûº¯ÊýµÄ·µ»ØÖµ¸³¸øÄãµÄ
namespace
¶ÔÏó
YAHOO.myProject.myModule = function () {
      
return 
{
      
      
myPublicProperty: "I'm accessible as
YAHOO.myProject.myModule.myPublicProperty.",
             
myPublicMethod:
function () {
                    
YAHOO.log("I'm
accessible as YAHOO.myProject.myModule.myPublicMethod.");
             
}
      
};
}(); // the parens here cause the anonymous function to execute and
return
×¢Òâ×îºóÒ»ÐеÄÖÐÀ¨ºÅÒÔ¼°Ô²À¨ºÅ
——
Õâ¸ö·ûºÅ´ÙʹÄäÃûº¯ÊýÁ¢¼´Ö´ÐУ¬·µ»ØÁËÒ»¸ö¶ÔÏ󣬸öÔÏó°üº¬
myPublicProperty
ºÍ
myPublicMethod
Á½¸öÊôÐÔ¡£ÄäÃûº¯ÊýÒ»·µ»Ø£¬¸Ã¶ÔÏó¾Í¿ÉÒÔͨ¹


Ïà¹ØÎĵµ£º

JavaScript »ñÈ¡¶ÔÏóµÄ¸ß¶ÈºÍ¿í¶ÈÏêϸ˵Ã÷

scrollHeight: »ñÈ¡¶ÔÏóµÄ¹ö¶¯¸ß¶È¡£
scrollLeft:ÉèÖûò»ñȡλÓÚ¶ÔÏó×ó±ß½çºÍ´°¿ÚÖÐÄ¿Ç°¿É¼ûÄÚÈݵÄ×î×ó¶ËÖ®¼äµÄ¾àÀë
scrollTop:ÉèÖûò»ñȡλÓÚ¶ÔÏó×¶ËºÍ´°¿ÚÖпɼûÄÚÈݵÄ×¶ËÖ®¼äµÄ¾àÀë
scrollWidth:»ñÈ¡¶ÔÏóµÄ¹ö¶¯¿í¶È
offsetHeight:»ñÈ¡¶ÔÏóÏà¶ÔÓÚ°æÃæ»òÓɸ¸×ø±ê offsetParent ÊôÐÔÖ¸¶¨µÄ¸¸×ø±êµÄ¸ß¶È
offsetL ......

Zakas½â´ðBaranovskiyµÄJavaScriptС²âÊÔ

תÔØ×Ô£ºhttp://hikejun.com/blog/?p=536
Zakas 1/22ÔÚtwitterÉÏ·ÖÏíÁËBaranovskiyµÄһƪÎÄÕ“So, you think you know JavaScript?
”£¨ÄãÈÏΪÄã¹»Á˽âjavascriptÂ𣩱êÌâºÜ½Ð°å¡£½á¹û5С¶Î´úÂë×öµÄÏ¡ÀﻩÀ²¡£
½ñÌìZakasרÃÅ׫ÎĽâ´ðÁËÕ⼸µÀÌ⣨http://www.nczonline.net/blog/2010/01/26/answering-baranov ......

javascript ½ûÖ¹¸´ÖÆÍøÒ³

1¡¢Ê¹ÓÒ¼üºÍ¸´ÖÆʧЧ
·½·¨1£º
ÔÚÍøÒ³ÖмÓÈëÒÔÏ´úÂ룺
<script language="Javascript">
document.oncontextmenu=new Function("event.returnValue=false");
document.onselectstart=new Function("event.returnValue=false");
</script>
·½·¨2£º
ÔÚ<body>ÖмÓÈëÒÔÏ´úÂ룺
<body oncontextm ......

̽ÃØIE8µÄÇ¿´óJavaScript¹¦ÄÜ

±¾ÎÄÀ´×Ôhttp://q.yesky.com/group/review-17634017.html£¬ÁíÍ⻹Ìí¼ÓһЩÀïÃæ¼¼ÊõµÄÁ´½Ó¡£
ÀëÏßʼþ(Online and offline events):
https://developer.mozilla.org/En/Online_and_offline_events
https://bug336359.bugzilla.mozilla.org/attachment.cgi?id=220609
http://ejohn.org/blog/offline-events/
postMessage ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ