JavaScript¾«´â¶ÁÊé±Ê¼Ç(5)
µÚ5Õ ¼Ì³Ð
ÔÚÄÇЩ»ùÓÚÀàµÄÓïÑÔ£¨±ÈÈçJava£©ÖУ¬¼Ì³Ð£¨inheritance»òextends£©ÌṩÁËÁ½¸öÓÐÓõķþÎñ¡£Ê×ÏÈ£¬ËüÊÇ´úÂëÖØÓõÄÒ»ÖÖÐÎʽ¡£Èç¹ûÒ»¸öеÄÀàÓëÒ»¸öÒÑ´æÔÚµÄÀà´ó²¿·ÖÏàËÆ£¬ÄÇôÄãÖ»Ðë¾ßÌå˵Ã÷Æ䲻ͬµã¼´¿É¡£Àà¼Ì³ÐµÄÁíÒ»¸öºÃ´¦ÊÇËü°üÀ¨ÁËÒ»Ì×ÀàÐÍϵͳµÄ¹æ·¶¡£ÓÉÓÚ³ÌÐòÔ±ÎÞÐë±àдÏÔʽÀàÐÍת»»µÄ´úÂ룬ËûÃǵŤ×÷Á¿½«´ó´ó¼õÇᣬÕâÊÇÒ»¼þºÜºÃµÄÊÂÇ飬ÒòΪÀàÐÍת»»Ê±»á¶ªÊ§ÀàÐÍϵͳÔÚ°²È«Éϵĺô¦¡£
JavaScriptÊÇÒ»ÃÅÈõÀàÐÍÓïÑÔ£¬´Ó²»ÐèÒªÀàÐÍת»»¡£¶ÔÏóµÄÆðÔ´ÊÇÎ޹ؽôÒªµÄ¡£¶ÔÓÚÒ»¸ö¶ÔÏóÀ´ËµÖØÒªµÄÊÇËüÄÜ×öʲô£¬¶ø²»ÊÇËü´ÓÄÄÀïÀ´¡£
JavaScriptÌṩÁËÒ»Ì׸üΪ·á¸»µÄ´úÂëÖØÓÃģʽ¡£Ëü¿ÉÒÔÄ£ÄâÄÇЩ»ùÓÚÀàµÄģʽ£¬Í¬Ê±ËüÒ²¿ÉÒÔÖ§³ÖÆäËû¸ü¾ß±íÏÖÁ¦µÄģʽ¡£ÔÚJavaScriptÖпÉÄܵļ̳ÐģʽÓкܶࡣÔÚ±¾ÕÂÖУ¬ÎÒÃǽ«Ñо¿¼¸ÖÖ×îΪֱ½ÓµÄģʽ¡£µ±È»»¹Óиü¶à¸üΪ¸´ÔӵĽṹ£¬µ«±£³ÖËüµÄ¼òµ¥Í¨³£ÊÇ×îºÃµÄ¡£
ÔÚ»ùÓÚÀàµÄÓïÑÔÖУ¬¶ÔÏó ÊÇÀàʵÀý£¬²¢ÇÒÀà¿ÉÒÔ´ÓÁíÒ»¸öÀà¼Ì³Ð¡£JavaScriptÊÇÒ»ÃÅ»ùÓÚÔÐ͵ÄÓïÑÔ£¬ÕâÒâζ×ŶÔÏóÖ±½Ó´ÓÆäËû¶ÔÏó¼Ì³Ð¡£
5.1 αÀà
µ±Ò»¸öº¯Êý¶ÔÏó±»´´½¨Ê±£¬Function¹¹ÔìÆ÷²úÉúµÄº¯Êý¶ÔÏó»áÔËÐÐÀàËÆÕâÑùµÄһЩ´úÂ룺
this.prototype={constructor:this};
к¯Êý¶ÔÏ󱻸³ÓèÒ»¸öprototypeÊôÐÔ£¬ÆäÖµÊÇ°üº¬Ò»¸öconstructorÊôÐÔÇÒÊôÐÔֵΪ¸Ãк¯Êý¶ÔÏ󡣸Ãprototype¶ÔÏóÊÇ´æ·Å¼Ì³ÐÌØÕ÷µÄµØ·½¡£ÒòΪJavaScriptÓïÑÔûÓÐÌṩһÖÖ·½·¨È¥È·¶¨Äĸöº¯ÊýÊÇ´òËãÓÃÀ´×÷¹¹ÔìÆ÷µÄ£¬ËùÒÔÿ¸öº¯Êý¶¼»áµÃµ½Ò»¸öprototype¶ÔÏó¡£constructorÊôÐÔûʲôÓá£ÖØÒªµÄÊÇprototype¶ÔÏó¡£
µ±²ÉÓù¹ÔìÆ÷µ÷ÓÃģʽ£¬¼´Ê¹ÓÃnewǰ׺ȥµ÷ÓÃÒ»¸öº¯Êýʱ£¬Õ⽫Ð޸ĺ¯ÊýÖ´Ðеķ½Ê½¡£Èç¹ûnewÔËËã·ûÊÇÒ»¸ö·½·¨¶ø²»ÊÇÒ»¸öÔËËã·û£¬Ëü¿ÉÄÜ»áÏñÕâÑùÖ´ÐУº
Function.method(‘new’,function(){
//´´½¨Ò»¸öжÔÏó£¬Ëü¼Ì³Ð×Ô¹¹ÔìÆ÷º¯ÊýµÄÔÐͶÔÏó¡£
var that=Object.beget(this.prototype);
//µ÷Óù¹ÔìÆ÷º¯Êý£¬°ó¶¨thisµ½Ð¶ÔÏóÉÏ¡£
var other = this.apply(that,arguments);
//Èç¹ûËüµÄ·µ»ØÖµ²»ÊÇÒ»¸ö¶ÔÏ󣬾ͷµ»Ø¸ÃжÔÏó
return (typeof other === ‘object’ && other)||that;
});
Ïà¹ØÎĵµ£º
Ò»¡¢¸ÅÊö
¿¼ÂÇHtml±¾Éí²»´ø¶¨Ê±Ë¢ÐÂÒ³ÃæµÄ¿Ø¼þ£¬ÇÒ²»¿¼ÂÇʹÓõÚÈý·½¿Ø¼þ£»Òò´Ë¿¼ÂÇʹÓÃJavascriptÖеÄsetTimeout+xmlhttpÀ´ÊµÏÖ¶¨Ê±¸üÐÂÒ³ÃæÖв¿·ÖÄÚÈÝ£¬´ËʵÏÖÔÚIE6.0¼°ÒÔÉÏ°æ±¾²âÊÔͨ¹ý£¬ÆäËûä¯ÀÀÆ÷ÔÝʱδ²âÊÔ¹ý¡£
¶þ¡¢¹¦Äܼ°Ìصã
1¡¢Javascriptͨ¹ýMicrosoftµÄMSXML¶ÔÏ󣬶¯Ì¬»ñÈ¡ºǫ́Êý¾Ý¿âÊý¾Ý£»
&n ......
Ò»¡¢¸ÅÊö
Marquee£ºHtmlÖйöÆÁ¿Ø¼þ£¬¿ÉÒÔʹ°üº¬Ôڴ˱ê¼ÇÖеÄÄÚÈݽøÐи÷¸ö·½Ïò£¬¸÷ÖÖËٶȵĹö¶¯£¬Òò´ËÔÚ²»¿¼ÂÇʹÓõÚÈý·½¿Ø¼þµÄÇ°ÌáÏ£¬¿¼ÂÇʹÓÃMarquee+xmlhttpÀ´ÊµÏÖ¶¨´Î¸üÐÂÒ³ÃæÖеĹö¶¯ÄÚÈÝ£¬´ËʵÏÖÔÚIE6.0¼°ÒÔÉÏ°æ±¾²âÊÔͨ¹ý£¬ÆäËûä¯ÀÀÆ÷ÔÝʱδ²âÊÔ¹ý¡£
MarqueeÖеÄonfinishʼþ£ºÔÚ¸øMarqueeÊôÐÔloop¸ ......
var myDate = new Date();
myDate.getYear(); //»ñÈ¡µ±Ç°Äê·Ý(2λ)
myDate.getFullYear(); //»ñÈ¡ÍêÕûµÄÄê·Ý(4λ,1970-????)
myDate.getMonth(); //»ñÈ¡µ±Ç°Ô·Ý(0-11,0´ú±í1 ......
ÔÚÄúµÄIEä¯ÀÀÆ÷ÉÏÔËÐк¬ÓÐJavaScript´úÂëµÄÒ³Ãæʱ¶¼»á²úÉúÒ»¸ö¾¯¸æ¡£Õâ¸ö“¾¯¸æ”ȷʵºÜ·³ÈË£¬²»ÖªÇéµÄÈË¿´ÁË»¹ÒÔΪÊDz¡¶¾Ê²Ã´ÄØ£¬ºÜÈÝÒ×ÈÃÈ˲úÉúÎó½â£¡
¼ÇµÃÍøÉÏÒ²ÓÐÈ˳ÆÆäΪ“IEµÄС»ÆÌõ¾¯¸æ”¡£¾ßÌåµÄʲô½Ð·¨ÎÒÃǽñÌì²»ÓùØÐÄ£¬ÎÒÃǹØÐĵÄÊÇÈçºÎÈ¥µôÕâ¸ö“¾¯¸æ”¡£¾ßÌå·½·¨ÈçÏ£º
µã»÷ ......
• Сд½ð¶îÓë´óд½ð¶îÁª¶¯
<mce:script language="JavaScript"><!--
function daxie()
{
this.values = ["Áã", "Ò¼", "·¡", "Èþ", "ËÁ", "Îé", "½", "Æâ", "°Æ", "¾Á"];
this.digits = ["", "Ê°", "°Û", "Ǫ"];
}
function daxie.prototype.getdx(num)
{
if(isNaN(num)) return "";
var number = ......