[JavaScript]ÀàÖ®Èý
Ïê½âjavascriptÀà¼Ì³Ð»úÖÆµÄÔÀí
Ŀǰ javascriptµÄʵÏּ̳з½Ê½²¢²»ÊÇͨ¹ý“extend”¹Ø¼ü×ÖÀ´ÊµÏֵ쬶øÊÇͨ¹ýconstructor functionºÍprototypeÊôÐÔÀ´ÊµÏּ̳С£Ê×ÏÈÎÒÃÇ´´½¨Ò»¸öanimalÀà
js ´úÂë
var animal = function(){ //Õâ¾ÍÊÇconstructor function ÁË
this.name = 'pipi';
this.age = 10;
this.height = 0;
}
//½¨Á¢Ò»¸ö¶¯ÎïµÄʵÀý
var a1 = new animal ();
¹¹Ô캯ÊýÓëÆäËûÆÕͨº¯ÊýÇø±ðÔÚÓÚ£¬1.¹¹Ô캯ÊýÀïÓÐ this¹Ø¼ü×Ö£¬2.µ÷Óù¹Ô캯ÊýÊÇʹÓõÄnew¹Ø¼ü×Ö¡£Í¨¹ýnewÔËËã·ûµ÷Óù¹Ô캯Êýanimal ºó£¬ÏµÍ³¾Í»á·µ»ØÒ»¸ö¶ÔÏó£¬Õâ¸ö¶ÔÏó¾ÍÏ൱ÓÚ
µÈͬÕâÑùµÄ·½Ê½À´²úÉújs¶ÔÏó¡£
µ½ÕâÀïÎÒÃÇÖªµÀÈçºÎÔÚjsÖж¨ÒåÒ»¸öÀàÁË£¬½ÓÏÂÀ´ÎÒÃÇչʾÈçºÎдһ¸öcat
js ´úÂë
var a1 = { name:'pipi' ,age:10,height:0 }
//»òÕß
var a1 = new Object();
a1.name='pipi';
a1.age = 10;
a1.height = 0;
js ´úÂë
var cat = function(){
this.play = function(){
alert('cat play')
}
}
cat .prototype = new animal ();
//prototype ÊôÐÔÖ¸ÏòÒ»¸ö¶ÔÏó
var c1 = new cat();
µ½ÕâÀcat¾Í¼Ì³ÐÁËanimal ¶ÔÏó£¬ÀàcatµÄÒ»¸öʵÀý¶ÔÏóc1ÓµÓÐÊôÐÔname,age,height,ºÍ·½·¨playÁË¡£
ÄÇôprototypeÆðµ½ÁËÒ»¸öʲôÑùµÄ×÷ÓÃÄØ£¿
prototype¾ÍºÃ±ÈÒ»¸öÖ¸Õ룬ËüÖ¸ÏòÒ»¸öobject£¬Õâ¸öobject¾Í³ÆÎª×ÓÀà¶ÔÏóµÄÔÐÍ¡£µ±catµÄ¶ÔÏó±»´´½¨µÄʱºò£¬ÓÉÓÚcatµÄ¹¹Ô캯ÊýÓµÓÐprototypeÊôÐÔ£¬ÄÇôcatµÄʵÀý¾Í»á¼ä½ÓÖ¸ÏòÕâ¸öÔÐͶÔ
Ïà¹ØÎĵµ£º
¶þÊ®¡¢Bookmarklet
1¡¢Ê²Ã´ÊÇBookmarklet£¿£¨What's a Bookmarklet?£©
Q£ºÊ²Ã´ÊÇBookmarklet£¿
A£ºBookmarkletÊÇÕû¸ö¶¼±»°üº¬ÔÚ³¬Á´½ÓURLÖеÄһС¶ÎJavaScript³ÌÐò¡££¨JavaScript URL¾ÍÊÇÕâ¸öÑù×Ó£º<a href="javascript:the code goes here">¡££©¶àÊýä¯ÀÀÆ÷ÔÊÐíÓû§Ìí¼ÓÕâЩJavaScript URLÊéÇ©£¬¾ÍÏñÌí¼ÓÆäËû³¬Á´½ ......
Ô´´úÂëÈçÏ£º
<!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>
<title>ÑéÖ¤ÓÊÏ䵨ַºÏ·¨ÐÔ</title>
<sc ......
Ò»¡¢ÔÚHTMLÖÐǶÈëJavasriptµÄ·½·¨
Ö±½ÓÔÚJavascript´úÂë·ÅÔÚ±ê¼Ç¶Ô<script>ºÍ</script>Ö®¼ä
ÓÉ<script />±ê¼ÇµÄsrcÊôÐÔÖÆ¶¨ÍⲿµÄjsÎļþ
·ÅÔÚʼþ´¦Àí³ÌÐòÖУ¬±ÈÈ磺<p onclick="alert('ÎÒÊÇÓÉonclickʼþÖ´ÐеÄJavascript')">µã»÷ÎÒ</p>
×÷ΪURLµÄÖ÷Ì壬Õâ¸öURLʹÓÃÌØÊâµÄJavascript ......
˼·£ºä¯ÀÀͼƬ£¬¶ÁÈ¡Æä¿í¶ÈImageW£¬¸ß¶ÈÖµImageH¡£¶ÁÈ¡Óû§ÊäÈëµÄ·Ö³É¼¸ÐÐRow¼¸ÁÐCol¡£
ÿ¸ö·½¿é£ºboxW=ImageW/Col£»boxH=ImageH/Row£»
ÔÚ1µ½Row*ColÖÐËæ»ú£¬µÚi¸öͼƬµÄλÖÃÉèΪpos¡¾i¡¿¡£È»ºó¶¯Ì¬´´½¨divÉú³ÉRow* ......
±ê×¼µÄWeb ×é³ÉÓ¦¸Ã°üÀ¨3 ²¿·Ö£º½á¹¹¡¢ÐÐΪºÍ±íÏÖ¡£ÕâÖÖ˼Ïë×îÔçÔÚ΢ÈíÉè¼ÆµÄ
DHTMLÄ£ÐÍÖгõ²½Ìá³öÀ´£¬µ«ÊǺܲ»¹æ·¶£¬Ò²²»³Éϵͳ¡£ºóÀ´£¬W3C£¨World Wide Web
Consortium£¬ÍòÎ¬ÍøÁªÃË£©×éÖ¯¹æ·¶ÁËWeb µÄ¹¹³É¡£¸ù¾ÝW3C ÖÆ¶©µÄ±ê×¼£¬Web ±ê×¼²»
ÊÇijһ¸ö±ê×¼£¬¶øÊÇһϵÁбê×¼µÄ¼¯ºÏ¡£ÍêÕûµÄWeb Ó¦¸ÃÓÉÒÔÏÂ3 ²¿·Ö×é³É£º
½á ......