JavaScript¼¼ÇÉ
ת»¯ÎªBooleanÀàÐÍ
ËùÓÐJavaScriptÖеÄÖµ¶¼ÄÜÒþʽµÄת»¯ÎªBooleanÀàÐÍ£¬±ÈÈ磺
0 == false; // true
1 == true; // true
'' == false // true
null == false // true
µ«ÊÇÕâЩֵ¶¼²»ÊÇBooleanÀàÐÍ¡£
Òò´Ëµ±ÎÒÃÇʹÓÃÈý¸öµÈÓںŽøÐбȽÏʱ£º
0 === false; // false
1 === true; // false
'' === false // false
null === false // false
ÏÖÔÚµÄÎÊÌâÊÇÈçºÎ½«ÆäËûÀàÐÍת»¯ÎªBooleanÀàÐÍ£º
!!0 === false; // true
!!1 === true; // true
!!'' === false // true
!!null === false // true
Ϊ²ÎÊý¸³³õÖµ
JavaScriptÖÐûÓÐÖØÔصĸÅÄµ«ÊÇJavaScriptÖк¯ÊýµÄ²ÎÊý¶¼ÊÇ¿ÉÑ¡µÄ£¬Èç¹ûµ÷ÓÃʱÉÙдÁËÒ»¸ö²ÎÊý£¬½«»á±»undefined
Ëù´úÌæ¡£
function plus(base, added) {
return base + added;
}
plus(2); // NaN
ÔÚÕâ¸öÀý×ÓÖУ¬plus(2)
ºÍplus(2, undefined)
Êǵȼ۵ģ¬2 + undefined
µÄ½á¹ûÊÇNaN
¡£
ÏÖÔÚµÄÎÊÌâÊÇ£¬Èç¹ûûÓд«µÝµÚ¶þ¸ö²ÎÊý£¬ÈçºÎΪËü¸³³õÖµÄØ£¿
function plus(base, added) {
added = added || 1;
return base + added;
}
plus(2); // 3
plus(2, 2); // 4
ÓÐÍøÓÑÌáµ½ plus(2, 0) = 3; µÄÈ·ÊÇÕâÑùµÄ£¬¿´À´Õâ¸öµØ·½»¹Òª×öһЩÌØÊâ´¦Àí£º
function plus(base, added) {
added = added || (added === 0 ? 0 : 1);
return base + added;
}
×èÖ¹±ðÈËÔÚIframeÖмÓÔØÄãµÄÒ³Ãæ
Èç¹ûÄãµÄÍøÕ¾±äµÃ·Ç³£ÓÐÈËÆøµÄʱºò£¬¾ÍÓкܶàÍøÕ¾ÏëÁ´½Óµ½ÄãµÄÍøÕ¾£¬ÉõÖÁÏë°ÑÄãµÄÍøҳͨ¹ýIFrameǶÈëËü×Ô¼ºµÄÍøÒ³¡£
ÕâÑù¾Í²»ºÃÍæÁË£¬ÄÇôÈçºÎÀ´×èÖ¹ÕâÑùÐÐΪÄØ£¿
if(top !== window) {
top.location.href = window.location.href;
}
Õâ¶Î´ú
Ïà¹ØÎĵµ£º
ʼþÔ´¶ÔÏó
event.srcElement.tagName
event.srcElement.type
²¶»ñÊÍ·Å
event.srcElement.setCapture();
event.srcElement.releaseCapture();
ʼþ°´¼ü
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
ʼþ·µ»ØÖµ
event ......
//¸÷Öֳߴç
s += "\r\nÍøÒ³¿É¼ûÇøÓò¿í£º"+ document.body.clientWidth;
s += "\r\nÍøÒ³¿É¼ûÇøÓò¸ß£º"+ document.body.clientHeight;
s += "\r\nÍøÒ³¿É¼ûÇøÓò¸ß£º"+ document.body.offsetWeight +" (°üÀ¨±ßÏߵĿí)";
s += "\r\nÍøÒ³¿É¼ûÇøÓò¸ß£º"+ document.body.offsetHeight +" ......
¹«Ë¾ÏîÄ¿ÏëҪʵÏÖÒ»ÖÖ¹¦ÄÜ£º
µ¥»÷Ò»¸ö°´Å¥»ò³¬Á´½Ó£¬È»ºó»á³öÏÖÆäËûµÄ³¬Á´½Ó£¬ÕâʱҪÈÃÆäÖеÄÒ»¸ö³¬Á´½Ó±»µ¥»÷£¬ÒÔÏÔʾһ¸ö³õʼҳÃæ¡££¨¹«Ë¾Ò³ÃæʹÓÃÁËframeset£©
ºÜÏÔÈ»£¬Ö®ºóµÄ³¬Á´½Óµ¥»÷ʼþÐèҪͨ¹ýJavaScriptÀ´´¥·¢¡£
Ò»¿ªÊ¼£¬ÎÒÏëµ½ÁËÓÃjQueryµÄclick()ʼþÀ´´¥·¢³¬Á´½ÓµÄµ¥»÷ʼþ£¨Óëtrigger("click")Ò ......
ShowModalDialogº¯ÊýµÄ¹¦ÄÜ£º
´ò¿ªÒ»¸ö×Ó´°¿Ú£¬²¢ÇÒ¿ÉÓ븸´°¿ÚÏ໥´«µÝÊý¾Ý£¬ËüÓëwindow.openµÄ×î´óÇø±ð¾ÍÔÚÓÚÓÉShowModalDialog´ò¿ª×Ó´°¿Úºó£¬¸¸´°¿Ú½«²»ÄܲÙ×÷¡£
ʹÓ÷½·¨£º
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
²ÎÊý˵Ã÷£º
sURL
±ØÑ¡²ÎÊý£¬ÀàÐÍ£º×Ö·û´®¡£ÓÃÀ´Ö¸¶¨¶Ô»°¿òÒªÏ ......