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

javascriptдÀ෽ʽ֮Æß

7¡¢dojo.jsµÄдÀ෽ʽ
dojo×îÐÂÊÇ1.3.1ÁË£¬¼ÇµÃ07Äêʱ»¹ÊÇ0.4¡£ÎĵµÒ²½¥½¥¶àÁËÆðÀ´£¬ÓÃdojoµÄÒ²ÂýÂý¶àÁË¡£dojo»¹·¢²¼ÁËcore°æ£¬Ñ¹ËõºóÖ»ÓÐ
27kb¡£dojoÖÐÓÃdojo.declare·½·¨À´¶¨ÒåÒ»¸öÀà¡£dojo.declareµÄÔ´Âë¾Í²»ÌùÔÚÕâÀïÁË¡£dojo.declareÓÐÈý¸ö²Î
Êý£¬
²ÎÊý1£ºÀàÃûclassName
²ÎÊý2£º¼Ì³ÐµÄÀàsuperclass
²ÎÊý3£º¹¹ÔìÆ÷£¬·½·¨props
µ¥´¿µÄ¶¨ÒåÒ»¸öÀàʵ¼ÊÖ»Ðè´«µÚÒ»£¬ÈýÁ½¸ö²ÎÊý¡£ÒòΪÕâÀïÖ»ÌÖÂÛÈçºÎ¶¨ÒåÒ»¸öÀ࣬²»ÌÖÂۼ̳С£´úÂëÈçÏ£º
//¶¨ÒåÀàÃû
var className = "Person";
//¶¨Òå¹¹ÔìÆ÷¼°·½·¨
var proto = {
constructor : function(name){this.name=name;},
getName : function(){ return this.name;},
setName : function(name){ this.name = name;}
}
//¶¨ÒåÀàPerson
dojo.declare(className,null,proto);
//´´½¨Ò»¸ö¶ÔÏó
var p = new Person("tom");
console.log(p.getName());//tom
p.setName("jack");
console.log(p.getName());//jack
//²âÊÔinstanceof¼°p.constructorÊÇ·ñÕýÈ·Ö¸ÏòÁËPerson
console.log(p instanceof Person);//true
console.log(p.constructor === Person);//true


Ïà¹ØÎĵµ£º

JavaScript ¶ÔÏóÓëÊý×é²Î¿¼´óÈ«

±¾ÎÄÁоÙÁ˸÷ÖÖJavaScript¶ÔÏóÓëÊý×é,ͬʱ°üÀ¨¶ÔÉÏÊöÿһ¶ÔÏó»òÊý×éËùÍê³É¹¤×÷µÄ¼ò¶ÌÃèÊö,ÒÔ¼°ÓëÆäÏà¹ØµÄÊôÐÔ·½·¨,ÒÔ¼°Ê¼þ´¦Àí³ÌÐò¡£
¡¡¡¡B.1 anchor¶ÔÏó
¡¡¡¡Ê¹ÓÃ<A NAME=>±ê¼Ç´´½¨µÄHTMLÃèµãÄܱ»Ò»¸öÁ´½Ó×÷ΪĿ±êÈç¹ûêµã°üÀ¨HREF=ÌØÐÔ,ÔòËüÒ²ÊÇÒ»¸öÁ´½Ó¶ÔÏó¡£
¡¡¡¡anchor¶ÔÏóÊÇdocument¶ÔÏóµÄÒ»¸öÊôÐÔ,Ëü±¾Éíà ......

JavaScript ¶ÔÏóÓëÊý×é²Î¿¼´óÈ«

±¾ÎÄÁоÙÁ˸÷ÖÖJavaScript¶ÔÏóÓëÊý×é,ͬʱ°üÀ¨¶ÔÉÏÊöÿһ¶ÔÏó»òÊý×éËùÍê³É¹¤×÷µÄ¼ò¶ÌÃèÊö,ÒÔ¼°ÓëÆäÏà¹ØµÄÊôÐÔ·½·¨,ÒÔ¼°Ê¼þ´¦Àí³ÌÐò¡£
¡¡¡¡B.1 anchor¶ÔÏó
¡¡¡¡Ê¹ÓÃ<A NAME=>±ê¼Ç´´½¨µÄHTMLÃèµãÄܱ»Ò»¸öÁ´½Ó×÷ΪĿ±êÈç¹ûêµã°üÀ¨HREF=ÌØÐÔ,ÔòËüÒ²ÊÇÒ»¸öÁ´½Ó¶ÔÏó¡£
¡¡¡¡anchor¶ÔÏóÊÇdocument¶ÔÏóµÄÒ»¸öÊôÐÔ,Ëü±¾Éíà ......

javascript ÑéÖ¤´úÂëÕûÀí

//the common event,If your brower is firefox,you should use this function instead of "window.event"
function getEvent() {
if(document.all)
return window.event; //get ie event
func=getEvent.caller;
while(func!=null) {
......

javascriptÑéÖ¤1

function $id(s) {
    return document.getElementById(s);
}
//ÅжÏСÊý
function IsFloat(s) {
    if (!/^[+\-]?\d+(.\d+)?$/.test(s))
        return false;
    else
        return ......

javascriptдÀ෽ʽ֮Îå

5¡¢Óà ¹¹Ô캯Êý+Ô­ÐÍ ¶¨ÒåÒ»¸öÀࣻͬһ¹¹Ô캯Êý¿ÉÒÔ¶¨Òå³ö¶à¸öÀàÐÍ



/**
* $define дÀ๤¾ßº¯ÊýÖ®¶þ
* @param {Object} constructor
* @param {Object} prototype
*/
function $define(constructor,prototype) {
var c = constructor || function(){};
var p = prototype || {};
r ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ