JavaScriptÖÐÄäÃûº¯Êý£¬º¯ÊýÖ±½ÓÁ¿ºÍ±Õ°ü(ת)
ÔÎijö´¦: http://www.dnew.cn/post/196.htm
ÏÈ¿´ÏÂÏÂÃ漸ÖÖд·¨
1.function f(x){return x*x;};f(x);
2.(function(x){return x*x;})(x);
3.(function(x){return x*x;}(x));
µÚÒ»ÖÖÎÒÃÇÓ¦¸Ã¶¼ºÜÊìϤÁË£¬ÕâÊÇÎÒÃǾ³£Ê¹ÓõÄд·¨¡£µÚ¶þµÚÈýÖÖ¶¼ÊÇÄäÃûº¯ÊýµÄд·¨¡£
--------------------------------------------------------------------------------
µÚ¶þÖÖ
¿ÉÒÔÕâÑùÀí½â£º
•var f=function(x) {return x*x;};f()
ÄÇÎÒÃDz»Í¨¹ýfÕâ¸ö±äÁ¿À´ÒýÓú¯Êý¾ÍÊÇ
•function(){}()
È»¶øÕâÑù¿Ï¶¨ÊÇ´íÎóµÄ¾ÍÏñ
•var f=1+2;
•f=f*0;
Óë
•var f=1+2*0;
½á¹û²»Í¬Ò»Ñù¡£
ÒªµÃµ½ÕýÈ·½á¹ûÖ»ÄÜ£º
•f=(1+2)*0;
Ò²¾ÍÊÇÒªÃ÷È·µÄ±êʶ³ö³ÌÐò¿é,¼´£º
•(function(){})()
¿ÏÄãÓÐÒÉÎÊ£ºÀ¨ºÅ“()”µ½µ×ÊDz»ÊÇÆðµ½Á˱êʶ´úÂë¿éµÄ×÷Óã¿
ÎÒÃÇ¿ÉÒÔÓÃJavaScriptµÄÄÚÖú¯Êý¼ì²âһϣ¡
¾ÙÒ»¸ö×î¼òµ¥µÄÀý×Ó£º
•alert(4)
Õâ¶Î´úÂë»áµ¯³öÌáʾÄÚÈÝÊÇ“4”
¸Ä³ÉÕâÑù
•(alert)(4)
¿ÉÒÔ¿´µ½Ö´ÐеÄЧ¹ûºÍÉÏÒ»¶Î´úÂëÒ»Ñù¡£
ÕâÖÖÐÎʽµÄº¯ÊýÖ´ÐÐÒ²±»ºÜ¶àJavaScript¿ò¼ÜËù²ÉÓá£
--------------------------------------------------------------------------------
µÚÈýÖÖ£¬Èç¹ûÄãÓùýjsvm¿ò¼ÜµÄ»°¾Í»á·¢ÏÖÀïÃæµÄ´úÂëʹÓÃÁËÕâÖÖÐÎʽ¡£
ÄÇÈçºÎ½âÊ͵ÚÈýÖÖÇé¿öÄØ?
ΪÁËŪÃ÷°×ä¯ÀÀÆ÷ÊÇÈçºÎÀí½âÕâÑùµÄд·¨µÄ£¬ÎÒÃÇ¿ÉÒÔÀûÓÃÒ»ÏÂMozilla FirefoxµÄ´íÎó¿ØÖÆ̨¹¦ÄÜ¡£
ÔÚ´úÂëÖвåÈëÒ»¶Î´íÎó´úÂ룬´úÂë¶ÎÈçÏ£º
•(function(s){s+s}(1)).splice();
´ò¿ªMozilla FirefoxµÄ´íÎó¿ØÖÆ̨£¬¿ÉÒÔ¿´µ½ÓÐÈçϵĴíÎóÌáʾ
´íÎó£º (function (s) {})(1) has no properties
Ô´Îļþ£ºfile:///C:/Documents…….html
ÐУº18
¿ÉÒÔÈÏΪ£¬ä¯ÀÀÆ÷¶ÔÓÚ
•(function(s){s+s}(1))
ÕâÑùµÄ´úÂë°´ÕÕ
•(function (s) {s+s})(1)
À´½âÎöµÄ¡£
Ïà¹ØÎĵµ£º
ÒýÑÔ
prototypeÔ´×Ô·¨ÓÈí¼þ½çµÄ±ê×¼·ÒëΪ“ÔÐÍ”£¬´ú±íÊÂÎïµÄ³õʼÐÎ̬£¬Ò²º¬ÓÐÄ£ÐͺÍÑù°åµÄÒâÒå¡£
prototypeÊôÐÔ
JavaScriptµÄËùÓÐfunctionÀàÐ͵ĶÔÏó¶¼ÓÐÒ»¸öprototypeÊôÐÔ¡£Õâ¸öprototypeÊôÐÔ±¾ÉíÓÖÊÇÒ»¸ö object ÀàÐ͵ĶÔÏó£¬Òò´ËÎÒÃÇÒ²¿ÉÒÔ¸ ......
a href="javascript:if(confirm(
ÐüÉÍ·Ö£º0 - ½â¾öʱ¼ä£º2008-9-25 13:58
a href="javascript:if(confirm('http://hunter.51rc.com/ \n\nÎļþ²¢Î´ÒÀ Teleport Pro È¡»Ø£¬ÒòΪ ËüµÄÓò»ò·¾¶³¬¹ý¿ªÊ¼ÍøÖ·ÖÐÉèÖõķ¶Î§¡£ \n\nÄãÒª´Ó·þÎñÆ÷ÉÏ´ò¿ªËüÂð£¿'))window.location='http://hunter.51rc.com/'" tppabs="http://h ......
JavaScript½øÐÐGETºÍPOSTÇëÇó
WebÉÏ×î³£¼ûµÄÇëÇó¾ÍÊÇGETÇëÇó.ÿ´ÎÔÚä¯ÀÀÆ÷ÖÐÊäÈëURL²¢´ò¿ªÒ²Ã×ÄÉÊÐ,¾ÍÊÇÔÚÏò·þÎñÆ÷·¢ËÍÒ»¸öGETÇëÇó.
GETÇëÇó£º
GETÇëÇóµÄ²ÎÊýʹÓÃÎʺÅ×·¼Óµ½URLµÄ½áβ,ºóÃ×ÄɸøÕâÓÃ&ºÃÁ¬½ÓÆðÀ´µÄÃû³Æ/Öµ.ÀýÈç:
http://www.somewhere.com/page.php?name1=value1&name2=value2&name3=value3
......
JavaScript ʼþ·½·¨
http://www.webdeveloping.cn/blog/?action=show&id=207
ʼþÔ´¶ÔÏó
event.srcElement.tagName
event.srcElement.type
²¶»ñÊÍ·Å
event.srcElement.setCapture();
event.srcElement.releaseCapture();
ʼþ°´¼ü
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
ʼþ·µ»ØÖµ
......
function getCookies(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return '';
}
function setCookie(name, value, expires, path, domain, secure)
{
var liveDate = new Date();
expires = l ......