JavaScriptÅжÏä¯ÀÀÆ÷ÀàÐͼ°°æ±¾
ÄãÖªµÀÊÀ½çÉÏÓжàÉÙÖÖä¯ÀÀÆ÷Â𣿳ýÁËÎÒÃÇÊìÖªµÄIE, Firefox, Opera, SafariËÄ´óä¯ÀÀÆ÷Ö®Í⣬ÊÀ½çÉÏ»¹Óнü°ÙÖÖä¯ÀÀÆ÷¡£
¼¸ÌìÇ°£¬ä¯ÀÀÆ÷¼Ò×åÓиյ®ÉúÁËһλСÍõ×Ó£¬¾ÍÊÇGoogleÍƳöµÄChromeä¯ÀÀÆ÷¡£ÓÉÓÚChrome³öÉúÃûÃÅ£¬¾¡¹ÜËû»¹ÊǸöС¼Ò»ï£¬Ã»ÓÐÈ˸ÒС¿´Ëû¡£ÒÔºó£¬ÔÛÃdz£Ëµä¯ÀÀÆ÷µÄ“ËÄ´ó²Å×Ó”¾ÍµÃ¸Ä³ÆΪ“Îå¶ä½ð»¨”ÁË¡£
ÔÚÍøվǰ¶Ë¿ª·¢ÖУ¬ä¯ÀÀÆ÷¼æÈÝÐÔÎÊÌâ±¾ÒÑÈÃÎÒÃÇÊÖæ½ÅÂÒ£¬ChromeµÄ³öÊÀ²»ÖªµÀÓÖÒª¸øÎÒÃÇÌí¶àÉÙÂÒ×Ó¡£ä¯ÀÀÆ÷¼æÈÝÐÔÊÇÇ°¶Ë¿ª·¢¿ò¼ÜÒª½â¾öµÄµÚÒ»¸öÎÊÌ⣬Ҫ½â¾ö¼æÈÝÐÔÎÊÌâ¾ÍµÃÊ×ÏÈ׼ȷÅжϳöä¯ÀÀÆ÷µÄÀàÐͼ°Æä°æ±¾¡£
JavaScriptÊÇÇ°¶Ë¿ª·¢µÄÖ÷ÒªÓïÑÔ£¬ÎÒÃÇ¿ÉÒÔͨ¹ý±àдJavaScript³ÌÐòÀ´ÅжÏä¯ÀÀÆ÷µÄÀàÐͼ°°æ±¾¡£JavaScriptÅжÏä¯ÀÀÆ÷ÀàÐÍÒ»°ãÓÐÁ½ÖÖ°ì·¨£¬Ò»ÖÖÊǸù¾Ý¸÷ÖÖä¯ÀÀÆ÷¶ÀÓеÄÊôÐÔÀ´·Ö±æ£¬ÁíÒ»ÖÖÊÇͨ¹ý·ÖÎöä¯ÀÀÆ÷µÄuserAgentÊôÐÔÀ´Åжϵġ£ÔÚÐí¶àÇé¿öÏ£¬ÖµÅжϳöä¯ÀÀÆ÷ÀàÐÍÖ®ºó£¬»¹ÐèÅжÏä¯ÀÀÆ÷°æ±¾²ÅÄÜ´¦Àí¼æÈÝÐÔÎÊÌ⣬¶øÅжÏä¯ÀÀÆ÷µÄ°æ±¾Ò»°ãÖ»ÄÜͨ¹ý·ÖÎöä¯ÀÀÆ÷µÄuserAgent²ÅÄÜÖªµÀ¡£
ÎÒÃÇÏÈÀ´·ÖÎöһϸ÷ÖÖä¯ÀÀÆ÷µÄÌØÕ÷¼°ÆäuserAgent¡£
IE
Ö»ÓÐIEÖ§³Ö´´½¨ActiveX¿Ø¼þ£¬Òò´ËËýÓÐÒ»¸öÆäËûä¯ÀÀÆ÷ûÓеĶ«Î÷£¬¾ÍÊÇActiveXObjectº¯Êý¡£Ö»ÒªÅжÏwindow¶ÔÏó´æÔÚActiveXObjectº¯Êý£¬¾Í¿ÉÒÔÃ÷È·Åжϳöµ±Ç°ä¯ÀÀÆ÷ÊÇIE¡£¶øIE¸÷¸ö°æ±¾µäÐ͵ÄuserAgentÈçÏ£º
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT)
ÆäÖУ¬°æ±¾ºÅÊÇMSIEÖ®ºóµÄÊý×Ö¡£
Firefox
FirefoxÖеÄDOMÔªËض¼ÓÐÒ»¸ögetBoxObjectForº¯Êý£¬ÓÃÀ´»ñÈ¡¸ÃDOMÔªËصÄλÖúʹóС£¨IE¶ÔÓ¦µÄÖÐÊÇgetBoundingClientRectº¯Êý£
Ïà¹ØÎĵµ£º
ÒòΪJSON ÊÇ javascript µÄÒ»¸ö×Ó¼¯£¬ËùÒÔ£¬ÔÚjavascript ÖÐʹÓÃJSONÊǷdz£¼òµ¥µÄ¡£
js ´úÂë
var myJSONObject = {"bindings": [
{"ircEvent": "PRIVMSG", "method":&n ......
ÔÚjsÖУ¬Ã¿¸ö¶ÔÏó¶¼ÓÐÒ»¸öprototypeÊôÐÔ£º·µ»Ø¶ÔÏóÀàÐÍÔÐ͵ÄÒýÓ᣺ÜÞÖ¿Ú£¡Ï°Óï“ÒÀºù«»Æ°”£¬ÕâÀïµÄºù«¾ÍÊÇÔÐÍ£¬ÄÇô“Æ°.prototype” ·µ»ØµÄ¾ÍÊǺù«£¬»òÕß“Æ°.prototype= new ºù«()”¡£
prototypeµÄÓÃ;£º
¼Ì³Ð
ÓÐÒ»¸ö¶ÔÏó££×ÓÀࣺ
function ×ÓÀà() {
this.lastname = ......
¶¨ÒåÓëÓ÷¨
The prototype property allows you to add properties and methods to an
object.
prototypeÊôÐÔÔÊÐíÄãÏòÒ»¸ö¶ÔÏóÌí¼ÓÊôÐԺͷ½·¨
Syntax
Óï·¨
object.prototype.name=value
Example 1
ʵÀý
In this example we will show how to use the prototype property to add a
property to an object:
ÔÚÏÂ ......
ÕâÈý¸öÓïÑÔ·Ö±ðÊÇÈý¸ö¹«Ë¾¿ª·¢µÄ£¬SUNµÄJava£¬NetscapeµÄJavaScript£¬MicrosoftµÄJScript
JavaScriptÊÇÓÉNetscape¹«Ë¾¿ª·¢²¢ËæNavigatorµ¼º½ÕßÒ»Æð·¢²¼µÄ¡¢½éÓÚJavaÓëHTMLÖ®¼ä¡¢»ùÓÚ¶ÔÏóʼþÇý¶¯µÄ±à³ÌÓïÑÔ£¬²»ÐèÒªJava±àÒëÆ÷£¬¶øÊÇÖ±½ÓÔËÐÐÔÚWebä¯ÀÀÆ÷ÖУ¬ËüµÄÇ°ÉíÊÇLive Script¡£
JScriptÊÇÒ»ÖÖÀàËÆJavaScriptµÄÓïÑÔ¡ ......