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

javascriptÉè¼Æģʽ_µÚ¶þ²¿·Ö_µ¥Ìåģʽ

 µ¥Ìåģʽ
Óŵã:°Ñ´úÂë×éÖ¯µÃÒ»Ö²¢¸ôÀë,¸üÈÝÒ×ÔĶÁºÍά»¤,Ìá¸ßÎȶ¨ÐÔ;ÓÃÓÚÓÅ»¯,ÌáÉýÐÔÄÜ
ȱµã:¿Éµ¼ÖÂÇ¿ñîºÏ
5.1 µ¥ÌåµÄ»ù±¾½á¹¹
var Singleton = {
attribute1 : true,
attribute2 : 10,

method1 : function(){},
method2 : function(){}
};

Ñϸñ°´¶¨ÒåÀ´Ëµ,C1²»ÊÇÒ»¸öµ¥Ìå,ÒòΪËü²»ÊÇÒ»¸ö¿ÉʵÀý»¯µÄÀà
¶ÔÏó×ÖÃæÁ¿Ö»ÊÇ´´Òâµ¥ÌåµÄ·½Ê½Ö®Ò».
²¢·ÇËùÓеĶÔÏó×ÖÃæÁ¿¶¼Êǵ¥Ìå,Ö»ÓÃÀ´Ä£·Â¹ØÁªÊý×é¼°ÈÝÄÉÊý¾ÝµÄ¾Í²»Êǵ¥Ìå.
5.2 »®·ÖÃüÃû¿Õ¼ä
var MyNamespace = {}
MyNamespace.common = {};

5.3 ÓÃ×÷Ìض¨ÍøҳרÓôúÂëµÄ°ü×°Æ÷µÄµ¥Ìå
GiantCorp.RegPage = {
FORM_ID : 'reg-form',
//method
handSubmit : function(e){
e.preventDefault();
//...
GiantCorp.RegPage.sendRegistration();
},
init : function(){
GiantCorp.RegPage.formEl = $(GiantCorp.RegPage.FORM_ID);
addEvent(GiantCorp.RegPage.formEl,'submit',GiantCorp.RegPage.handSubmit);
}

};
addLoadEvent(GiantCorp.RegPage.init);
//ÒÔÉÏ´úÂ뽫ÊôÐÔ¼°·½·¨¶¼Í³Ò»µ½Ò»¸öµ¥ÌåÖÐ,²¢Í¨¹ýinitÀ´°ó¶¨Ê¼þ,×îºóÔÚÒ³ÃæÉϵ÷ÓÃinit¼´¿ÉʵÏÖÌض¨Ò³ÃæµÄʹÓÃ

ijÍøҳרÓôúÂë,×îºÃâÊÔÚ×Ô¼ºµÄµ¥Ìå¶ÔÏóÖÐ
5.4 ÓµÓÐ˽ÓóÉÔ±µÄµ¥Ìå
 1) Ï»®Ïß±íʾ·¨
GiantCorp.DataParser = {
//Private methods
_stripWhitespace : function(str){
return str.replace(/\s+/,'');
},
_stringSplit : function(str,delimiter){
return str.split(delimiter);
},
//Public method
stringToArray : function(str, delimiter,stripWS){
if(stripWS){
str = this._stripWhitespace(str);
}
var outputArray = this._stringSplit(str,delemiter);
return outputArray;
}
}

    2) ʹÓñհü
     MyNamespace.Singleton = (function(){
return {};
})();

ÕâÖÖ·½Ê½ÓëÖ±½ÓʹÓöÔÏó×ÖÃæÁ¿Ã»Ê²Ã´Çø±ð,µ«Õâ¸ö°ü×°º¯Êý´´½¨ÁËÒ»¸ö¿ÉÒÔÓÃÀ´Ìí¼Ó˽ÓóÉÔ±µÄ±Õ°ü,ÈκÎÌí¼ÓÔÚÕâ¸öÄäÃûº¯ÊýÖжø²»ÔÚ¶ÔÏó×ÖÃæÁ¿ÖеĶ¼½«³ÉΪ˽ÓгÉÔ±
MyNamespace.Singleton = (function(){
//Private members
var p1 = false;
var p2 = 10;
function p3(){}
return {
//Public members
pub1 : true,
pub2 : 10,
pub3 : functi


Ïà¹ØÎĵµ£º

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

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

javascript trim

×î½ü×öË°Îñ×ÛºÏƽ̨¹¤×÷Á÷£¬ ÔÚÒ³ÃæÉÏÅжÏÊÇ·ñÊÇ“»õ±Ò½ð¶î”¸ñʽ£¬Ê¹ÓõÄÊÇÕýÔò±í´ïʽ£¬Ò»Ö±¶¼Ã»ÓÐÎÊÌ⣬
ºóÀ´Í»È»ÎÞ·¨ÑéÖ¤£¬ ¾ÍÊDz»·ûºÏÕýÔò±í´ïʽµÄ½á¹¹£¬×îºóÖÕÓÚ·¢ÏÖ ½ð¶îºóÃæ°üº¬¿Õ¸ñ×Ö·û´®£¬ÔÚÍøÉÏÕÒµ½Ò»¶Î´úÂë £¬ÕýºÃ½â¾ö¡£
String.prototype.trim= function(){
   // ÓÃÕýÔò±í´ïʽ½«Ç°ºó¿ ......

JavascriptË¢ÐÂÒ³ÃæµÄ¼¸ÖÖ·½·¨

JavascriptË¢ÐÂÒ³ÃæµÄ¼¸ÖÖ·½·¨£º
³ÌÐò´úÂë
1    history.go(0) 
2    location.reload() 
3    location=location 
4    location.assign(location) 
5    document.execCommand('Refres ......

JavaScriptÖÐescapeº¯Êý

JavaScriptÖÐescape() º¯Êý¿É¶Ô×Ö·û´®½øÐбàÂ룬ÕâÑù¾Í¿ÉÒÔÔÚËùÓеļÆËã»úÉ϶ÁÈ¡¸Ã×Ö·û´®¡£Ê¹Ó÷½·¨£º
escape(charString)
charstringÊDZØÑ¡ÏҪ±»×ªÒå»ò±àÂëµÄ×Ö·û´®¡£
escape ·½·¨·µ»ØÒ»¸ö°üº¬ÁË charstring ÄÚÈݵÄ×Ö·û´®Öµ£¨ Unicode ¸ñʽ£©¡£ËùÓпոñ¡¢±êµã¡¢ÖØÒô·ûºÅÒÔ¼°ÆäËû·Ç ASCII ×Ö·û¶¼Óà %xx ±àÂë´úÌ棬ÆäÖ ......

Javascript ¼¼ÇÉ´óÈ«(2)

POST´úÌæFORM
<SCRIPT language="VBScript">
Function URLEncoding(vstrIn)
    strReturn = ""
    For i = 1 To Len(vstrIn)
        ThisChr = Mid(vStrIn,i,1)
        If Abs(Asc(ThisChr)) ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ