[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();
½éÉÜÍê±Ï£¬ÊÕ¹¤¡£¡£¡£¡£
Ïà¹ØÎĵµ£º
[×¢:Ò³ÃæÉÏÔªËØnameÊôÐÔºÍJavaScriptÒýÓõÄÃû³Æ±ØÐëÒ»Ö°üÀ¨´óСд£¬·ñÔò»áÌáʾÄãÒ»¸ö´íÎóÐÅÏ¢ "ÒýÓõÄÔªËØÎª¿Õ»òÕß²»ÊǶÔÏó"]
========================================================================
¶ÔÏóÊôÐÔ:
document.title //ÉèÖÃÎÄ ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡Ïûѡȡ¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="return f ......
<a class="bt_3" href="javascript:void(0)" mce_href="javascript:void(0)" id="btnSubmit1" onclick="submitPage()">Ìá½»</a>
submitPage() ÊÇÎÒ¶¨ÒåµÄÒ»¸öº¯Êý£¬ÔÒâÊǵã»÷Õâ¸ö<a>ʱ£¬Ìá½»Ò»¸ö±íµ¥¡£ft, ie6 ¾ÓÈ»²»¿ÉÒÔ£¬ÔõôҲ²»ÄÜÌá½»¡£
¿´À´ÊÇÒòΪ ie6 Ö´ÐÐĬÈ϶¯×÷ÒýÆðÀ´£¬Ä¿Ç°Á½ÖÖ½â¾ö·½·¨£ ......
1.´´½¨½Úµã²¢Ìí¼ÓÄÚÈÝ:ʹÓõķ½·¨:createElementºÍcreateTextNode
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HTML DOM</title>
&nbs ......