javascript ÖÐthis µÄÓ÷¨:
javascript ÖÐthis µÄÓ÷¨:
1.<div onclick="// ¿ÉÒÔÔÚÀïÃæʹÓÃthis">division element</div> this Ö¸Ïòdiv
2. <div id="elmtDiv">division element</div>
<script language="javascript">
var div = document.getElementById('elmtDiv');
div.attachEvent('onclick', EventHandler); //attachEvent°ÑdivµÄonclickʼþºÍÒ»¸ö·½·¨°ó¶¨
function EventHandler()
{
// ÔÚ´ËʹÓÃthis
}
</script>ÔÚ´Ëthis Ö¸Ïòwindow¶ÔÏó,ÈôÒªÒýÓÃdiv¶ÔÏóthis.event.srcElement;
3¡¢ÓÃDHTML·½Ê½ÔÚʼþ´¦Àíº¯ÊýÖÐʹÓÃthis¹Ø¼ü×Ö£º
<div id="elmtDiv">division element</div>
<script language="javascript">
var div = document.getElementById('elmtDiv');
div.onclick = function()
{
// ÔÚ´ËʹÓÃthis
};
</script>²úÉúµÄ·½·¨Í¬ÉÏ,µ«´Ë´¦µÄthis Ö¸Ïòdiv
4¡¢ÀඨÒåÖÐʹÓÃthis¹Ø¼ü×Ö£º
function JSClass()
{
var myName = 'jsclass';
this.m_Name = 'JSClass';
}
JSClass.prototype.ToString = function()
{
alert(myName + ', ' + this.m_Name);
};
var jc = new JSClass();
jc.ToString();//ÕâÊÇJavaScriptÄ£ÄâÀඨÒåÖжÔthisµÄʹÓã¬Õâ¸öºÍÆäËüµÄOOÓïÑÔÖеÄÇé¿ö·Ç³£µÄÏàʶ¡£µ«ÊÇÕâÀïÒªÇó³ÉÔ±ÊôÐԺͷ½·¨±ØÐëʹÓÃthis¹Ø¼ü×ÖÀ´ÒýÓã¬ÔËÐÐÉÏÃæµÄ³ÌÐò»á±»¸æÖªmyName䶨Òå¡£
5¡¢Îª½Å±¾ÒýÇæÄÚ²¿¶ÔÏóÌí¼ÓÔÐη½·¨ÖеÄthis¹Ø¼ü×Ö£º
Function.prototype.GetName = function()
{
var fnName = this.toString();
fnName = fnName.substr(0, fnName.indexOf('('
Ïà¹ØÎĵµ£º
<!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" lang="gb2312">
<head>
<head>
<title> ¹ØÓÚarguments,callee,callerµÈµÄ²âÊÔ &l ......
ÕýÔÚ¿´¡¡javascript¸ß¼¶³ÌÐòÉè¼Æ¡¡,ÆäÖйØÓÚ·Ö×éÀïÃæµÄÒ»¾ä´úÂë²»ÊÇÌ«Àí½â:
ͨ¹ýÅäºÏʹÓÃString¶ÔÏóµÄreplace()·½·¨¼°·´ÏòÒýÓ㬾ͿÉÒÔ¶¨Òå×Ô¼ºµÄtrim()·½·¨:
String.prototype.trim = function() {
var reExtraSpace = /^\s+(.*?)\s+$/;
return this.replace(reExtraSpace,"$1");
}
Ò»¿ªÊ¼ÔõôҲ²» ......
JavaScript ÊÇÒ»¿îÇ¿´óµÄ¹ã·ºÔËÓÃÓÚÏÖ´úWebÕ¾µã¼°Ó¦ÓõĽű¾ÓïÑÔ¡£×÷Ϊһ¸ö¼¼ÒÕ¾«Õ¿µÄ Web ¿ª·¢Õߣ¬ÕÆÎÕJavaScript¿ÉÒÔÔöÇ¿Óû§µÄʹÓÃÌåÑ飬Ìṩ½»»¥¼°¸»¿Í»§¶ËµÈ¹¦ÄÜ¡£
¾¡¹ÜJavaScript µÄÓï·¨·Ç³£¼òµ¥£¬µ«¶ÔÓÚд³ÌÐò¶øÑÔÈÔÈ»ÊÇÀ§ÄÑÖØÖØ£¬¾ÍÊÇÒòΪËüµÄÔËÐл·¾³£º»ùÓÚWebä¯ÀÀÆ÷¡£
ÒÔÏÂÄú¿ÉÒÔ¿´µ½ÊÕ¼¯µÄ8¸öʵÓÃµÄ JavaScr ......
50¸öʵÓõÄJavaScript¹¤¾ß- - JavaEye¼¼ÊõÍøÕ¾
JavaScriptÊÇÒ»¸ö¹¦ÄÜÇ¿´óµÄ¿Í»§¶Ë½Å±¾ÓïÑÔ£¬Ðí¶àÏÖ´ú»¯µÄÍøÕ¾ºÍWebÓ¦ÓóÌÐò¶¼»áʹÓõ½Ëü¡£JavaScript¿ÉÒÔÔöÇ¿Óû§µÄÌåÑ飬²¢Ìṩ·á¸»µÄ»¥¶¯Ê½×é¼þºÍ¹¦ÄÜ¡£ËäÈ»ËüµÄÓï·¨Ï൱¼òµ¥£¬µ«ÊǶԿª·¢ÕßÀ´Ëµ»¹ÊǺÜÓÐÄѶȵģ¬ÒòΪËüÒªÔËÐÐÔÚWebä¯ÀÀÆ÷ÖС£
¡¡¡¡ÒÔÏÂÊÇÎÒÃÇΪÄãÍƼöµÄ50¸ ......
ΪÁËÌá¸ßÍøÕ¾µÄ¼ÓÔØËٶȣ¬ÓÐÒ»¸öºÜÖØÒªµÄÊֶξÍÊÇÔÚÓû§ä¯ÀÀ¹ý³ÌÖеÄÉÏÓÎÍøÕ¾×öÒ»¸öÎļþµÄÔ¤¼ÓÔØ¡£Ô¤¼ÓÔØÎļþÒ»°ãÓÐÁ½ÖÖ³£Óõķ½Ê½£ºxhrºÍ¶¯Ì¬²åÈë½ÚµãµÄ·½Ê½¡£¶¯Ì¬²åÈë½ÚµãÊÇ×îΪ¼òµ¥Ò²×îΪ¹ã·ºµÄÒ»ÖÖÒì²½¼ÓÔØ·½Ê½(ÀýÈçyuiµÄGetÄ£¿é)£¬È»ºóʹÓö¯Ì¬²åÈë½Úµã·½·¨¼ÓÔصÄÎļþ¶¼»áÔÚ¼ÓÔغóÁ¢¼´Ö´ÐУ¬javascriptµÄÖ´ÐÐÒ»·½Ãæ»áÕ ......