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

JavaScriptµÄÁíÍâÁ½Öּ̳лúÖÆ

1>zInherit£º
      ËüÊÇÒ»¸ö×é¼þ£¬ÓÃÀ´¼Ì³Ð»ùÀàµÄËùÓÐÊôÐԺͷ½·¨¡£¸úÒÔǰ˵µ½µÄÔ­ÐÍÁ´Ä£Ê½·Ç³£ÀàËÆ£¬Ö»²»¹ý±ÈÔ­Ð͸ü°²È«£¬Ò²ÎÞÐ뿼ÂDzÎÊýÎÊÌâ¡£ÏÂÃæ¿´¿´zInheritµÄÓ÷¨£º
      ¸Ã×é¼þÖÐÖ»ÓÐÁ½¸ö·½·¨£ºinheritfrom() instanceof()
     function Polygon(iSides){
this.iSides = iSides;
if(typeof Polygon._initialized == "undefined"){
Polygon.prototype.getArea = function(){
return 0;
}
Polygon._initialized = true;
}
}
function Traingle(iHeight,iWidth){
Polygon.call(this,3);
this.iHeight = iHeight;
this.iWidth = iWidth;
if(typeof Traingle._initialized == "undefined"){
Traingle.inheritfrom(Polygon);
//ÉÏÐеÄЧ¹û¸úÔ­À´µÄÕâ¸ö·Ç³£ÀàËÆ
// Traingle.prototype = new Polygon();
Traingle.prototype.getArea = function(){
return 0.5*iHeight*iWidth;
}
Traingle._initialized = true;
}
}
var traingle = new Traingle(12,4);
alert(traingle.getArea());//24
    Note:ÔÚÖ´ÐÐǰ±ØÐë¼ÓÔØzInherit.js
2>xbObjects.js
    ËüÊÇÒ»¸ö¹¦ÄܸüÇ¿´óµÄ¼Ì³Ð»úÖÆ£¬³ýÁË¿ÉÒԼ̳лùÀàµÄÊôÐԺͷ½·¨Í⣬»¹¿ÉÒÔµ÷Óø¸ÀàµÄ·½·¨£¬ÔÚÖ´ÐÐǰҳ±ØÐëÔö¼Ó×é¼þxbObject.js.
 ¾ßÌåµÄ²½ÖèÈçÏ£º
   µÚÒ»²½£º×¢²áÀࣨ_classes.registerClass("sub_class","base_class") _classes.register("sub_class")£©
   µÚ¶þ²½£º¹¹Ô캯Êý£¬²¢ÔÚº¯ÊýÖж¨ÒåÀà(_classes.defineClass("class_name",prototypeFunction))
   µÚÈý²½£ºÖ´ÐÐinit£¨£©·½·¨£¬¸Ã·½·¨µÄ²ÎÊý±ØÐë¸ú¹¹Ô캯ÊýµÄ²ÎÊýÆ¥Åä
   µÚËIJ½£º¿ÉÒÔͨ¹ýparentMehtod("method_name",arguments)
   <mce:script type="text/javascript"><!--
//Polygon
_classes.registerClass("Polygon"); //1
function Polygon(iSides){ //2
_classes.defineClass("Polygon",prototypeFunction);
this.init(iSides);//³õʼ»¯PolygonµÄËùÓÐÊôÐÔ//3

function prototypeFunction(){//4
Polygon.prototype.init = function(iSides){
this.parentMethod("init");
this.iSides


Ïà¹ØÎĵµ£º

³£ÓõÄjavascriptÓï¾ä¼¯


×î¶ÌµÄÍ϶¯´úÂë
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script l ......

IEºÍFirefoxÔÚJavaScriptÓ¦ÓÃÖеļæÈÝÐÔ

1.document.formName.item("itemName") ÎÊÌâ
˵ Ã÷:IEÏÂ,¿ÉÒÔʹÓÃdocument.formName.item("itemName")»òdocument.formName.elements ["elementName"];FirefoxÏÂ,Ö»ÄÜʹÓÃdocument.formName.elements["elementName"].
½â¾ö·½·¨:ͳһʹÓÃdocument.formName.elements["elementName"].
2.¼¯ºÏÀà¶ÔÏóÎÊÌâ
˵Ã÷:IEÏÂ,¿ÉÒÔ ......

ËøÆÁJavaScriptƬ¶Î

var docEle = function() {
return document.getElementById(arguments[0]) || false;
}
function cloDiv(){
var overlayID="overlay";
var msgID = "overlayMsg";
document.body.removeChild(docEle(overlayID));
document.body.removeChild(docEle(msgID));
}
function openNewDiv() {
......

IEºÍFirefoxÔÚcss,JavaScript·½ÃæµÄ¼æÈÝÐÔ

1.document.formName.item("itemName") ÎÊÌâ
˵Ã÷:IEÏÂ,¿ÉÒÔʹÓÃdocument.formName.item("itemName")»òdocument.formName.elements["elementName"];FirefoxÏÂ,Ö»ÄÜʹÓÃdocument.formName.elements["elementName"].
½â¾ö·½·¨:ͳһʹÓÃdocument.formName.elements["elementName"].
2.¼¯ºÏÀà¶ÔÏóÎÊÌâ
˵Ã÷:IEÏÂ,¿ÉÒÔʹÓÃ() ......

Javascript²Ù×÷select¿Ø¼þ´óÈ«

1ÅжÏselectÑ¡ÏîÖРÊÇ·ñ´æÔÚValue="paraValue"µÄItem 
 2ÏòselectÑ¡ÏîÖР¼ÓÈëÒ»¸öItem 
 3´ÓselectÑ¡ÏîÖРɾ³ýÒ»¸öItem 
 4ɾ³ýselectÖÐÑ¡ÖеÄÏî 
 5ÐÞ¸ÄselectÑ¡ÏîÖРvalue="paraValue"µÄtextΪ"paraText" 
 6ÉèÖÃselectÖÐtext="paraText"µÄµ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ