[JAVASCRIPT] this ¶ÔÏó
¿´Á˺ܶàjavascrip´úÂ룬·¢ÏÖºÜ¶àµØ·½Óõ½ÁËthisÕâ¸ö¶ÔÏó£¬ÄÇÕâ¸öµ½µ×ÊÇʲô¶«Î÷°¢£¿
ÏÈÈÃÎÒÃÇÀ´Àí½âÒ»¸ö¸ÅÄ
ÔÚjavascript»áÓÐÒ»¸öÉÏÏÂÎĵĸÅÄÈκÎÒ»¸ö¶ÔÏóÎÞÂÛÊÇObject »¹ÊÇfunction ¶¼»áÓÐÒ»¸öרÓеÄÉÏÏÂÎĶÔÏó£¬Ò²¿ÉÒÔÀí½âΪËü×Ô¼ºµÄÓµÓÐÕß¡£
ÄÇôÎÒÃǺÜÈÝÒ×Ïëµ½Õâ¸öÓµÓÐÕߣ¬±ØÈ»ÓиöÖյ㣬ÄǾÍÊÇwindow¶ÔÏó¡£
ºÃÁË£¬ÄÇôÎÒÃÇÀí½âÁËÕâ¸ö¸ÅÄîºó£¬¼ÇסÒÔϼ¸¸ö¹æÔò£¬¾Í¿ÉÒÔ׼ȷµÄÅжÏthisµ½µ×Ö¸µÄÊǸöɶ×ÓÍæÒâ¶ù¡£
¶ÔÏóµÄ˽ÓжÔÏó£¬ÉÏÏÂÎÄÊǶÔÏó±¾Éí
ÄäÃûº¯ÊýµÄÉÏÏÂÎÄÊÇwindow
ÓÃnewµÄº¯ÊýÉÏÏÂÎÄΪÕâ¸ö¶ÔÏó
ÈÃÎÒÃÇÔÙÀ´¿´Ð©Àý×Ó°É£»
var testFun = function (){
alert(this);
};
testFun();
ÉÏÊöÀý×ӵĽá¹ûÊÇ window¶ÔÏó
var obj = {
getName : function() {
alert(this);
}
};
obj.getName();
ÉÏÊöÀý×ӵĽá¹ûÊÇÒ»¸öOBJECT
¸ù¾ÝÉÏÊöÀíÂÛ£¬º¯ÊýÖÐǶÌ×ÄäÃûº¯ÊýÓ¦¸ÃÒ²ÊÇWINDOW¶ÔÏó£¬À´¿´ÏÂÃæµÄ´úÂë
var obj = {
getName : function(){
var innerFun = function (){alert(this);}
}
};
obj.getName();
À´¿´¸ö¹¹Ô캯ÊýµÄÀý×Ó£¬thisÖ¸µÄÊǶÔÏó
var obj = function() {
alert(this);
};
var test = new obj();
test();
½éÉÜÍê±Ï£¬ÊÕ¹¤¡£¡£¡£¡£
Ïà¹ØÎĵµ£º
DOMÊÇÕë¶ÔXMLµÄ»ùÓÚÊ÷µÄAPI£¬ËüÓëÓïÑÔÎ޹أ¬ÊµÏÖ·½Ê½ÓкܶàÖÖ£¨¸÷ÓïÑÔ»ù±¾¶¼ÓÐ×Ô¼ºµÄʵÏÖ£©¡£
²»¹ýÎÒÃǾ³£Óõģ¬ÊÇJavaScript ϵÄdomÕë¶ÔxhtmlµÄ²Ù×÷£¬Ö»ÊÇdomµÄÒ»¸ö·ÖÖ§Ó¦Óá£
Ãû´Ê½âÊÍ£º
Dom£ºÎĵµ¶ÔÏóÄ£ÐÍ¡£Document object model
Bom£ºä¯ÀÀÆ÷¶ÔÏóÄ£ÐÍ£¬Ò²¿ÉÒԽд°¿Ú¶ÔÏóÄ£ÐÍ¡££¨window object model.£©
API£ºÓ ......
<a class="bt_3" href="javascript:void(0)" mce_href="javascript:void(0)" id="btnSubmit1" onclick="submitPage()">Ìá½»</a>
submitPage() ÊÇÎÒ¶¨ÒåµÄÒ»¸öº¯Êý£¬ÔÒâÊǵã»÷Õâ¸ö<a>ʱ£¬Ìá½»Ò»¸ö±íµ¥¡£ft, ie6 ¾ÓÈ»²»¿ÉÒÔ£¬ÔõôҲ²»ÄÜÌá½»¡£
¿´À´ÊÇÒòΪ ie6 Ö´ÐÐĬÈ϶¯×÷ÒýÆðÀ´£¬Ä¿Ç°Á½ÖÖ½â¾ö·½·¨£ ......
Javascript Closures
Introduction
The Resolution of Property Names on Objects
Assignment of Values
Reading of Values
Identifier Resolution, Execution Contexts and Scope Chains
The Execution Context
Scope chains and [[scope]]
Identifier Resolution
Closures
Automatic Garbage Collecti ......
ÔÚJavaScriptÖÐÀûÓÃdocument.referrer¿ÉÒÔ»ñµÃÌø×ªÇ°ÉÏÒ»Ò³µÄµØÖ·,ÆäʵÔÚÖîÈçAsp,PHPµÈÓïÑÔÖж¼¿ÉÒÔ»ñµÃÕâ¸ö²ÎÊý,Ö»²»¹ýд·¨²»Í¬,È»ºó¿ÉÒÔÅжÏÊÇÄÄÀïÀ´µÄÇëÇó´Ó¶ø×öһЩ´¦Àí.µ«ÊÇJSÖеÄdocument.referreÖ»ÄÜ»ñµÃ<a>±êÇ©´«¹ýÀ´µÄ²ÎÊý.¿´´úÂë
a.html
<html>
<head>
<title>²âÊÔ</title> ......
1.´´½¨½Úµã²¢Ìí¼ÓÄÚÈÝ:ʹÓõķ½·¨:createElementºÍcreateTextNode
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HTML DOM</title>
&nbs ......