JavaScript ¿ò¼Ü±È½Ï
JavaScript ¿ò¼Ü±È½Ï
ÏÔÖøÔöÇ¿ JavaScript ¿ª·¢µÄ¿ò¼Ü¸ÅÀÀ
Joe Lennon, Èí¼þ¿ª·¢ÈËÔ±, ×ÔÓÉÖ°ÒµÕß
¼ò½é£º ÏÖ´ú Web Õ¾µãºÍ Web Ó¦ÓóÌÐòÇãÏòÓÚÒÀÀµ´óÁ¿¿Í»§¶Ë JavaScript À´Ìṩ·á¸»µÄ½»»¥¹¦ÄÜ£¬ÓÈÆäÊÇÒì²½ HTTP ÇëÇóµÄ³öÏÖʹµÃ²»Ë¢ÐÂÒ³Ãæ¾Í¿ÉÒÔ´Ó·þÎñÆ÷¶Ë½Å±¾»òÊý¾Ý¿âϵͳ·µ»ØÊý¾Ý»òÏìÓ¦¡£ÔÚ±¾ÎÄÖУ¬Äú½«Á˽âÈçºÎͨ¹ý JavaScript ¿ò¼Ü¸üÇáËÉ¡¢¸ü¿ìËٵش´½¨¾ßÓи߶Ƚ»»¥ÐÔºÍÏìÓ¦Ð﵀ Web Õ¾µãºÍ Web Ó¦ÓóÌÐò¡£
¼ò½é
JavaScript ÊÇÃæÏò¶ÔÏóµÄ½Å±¾ÓïÑÔ£¬³¤ÆÚÒÔÀ´ÓÃ×÷ Web ä¯ÀÀÆ÷Ó¦ÓóÌÐòµÄ¿Í»§¶Ë½Å±¾½Ó¿Ú¡£JavaScript Èà Web ¿ª·¢ÈËÔ±ÄÜÒÔ±à³Ì·½Ê½´¦Àí Web Ò³ÃæÉϵĶÔÏ󣬲¢ÌṩÁËÒ»¸öÄܹ»¶¯Ì¬²Ù×÷ÕâЩ¶ÔÏóµÄƽ̨¡£ÔÚ×î³õÒýÈë JavaScript ʱ£¬Í¨³£Ö»ÓÃÓÚÌṩ Web Ò³ÃæÉϵÄһЩ²»ÖØÒªµÄÌØÐÔ£¬ÈçʱÖÓ¹¦ÄܺÍä¯ÀÀÆ÷״̬À¸ÖеĹö¶¯Îı¾µÈ¡£ÁíÒ»¸ö³£¼ûµÄÌØÐÔÊÇ “rollover link”£¬¾ÍÊǵ±Óû§½«Êó±êÒƵ½Í¼Æ¬»òÎı¾Á´½ÓÉÏʱ£¬Í¼Æ¬»òÎı¾Á´½ÓµÄÑÕÉ«»á¸Ä±ä¡£È»¶ø£¬½üÄêÀ´£¬Ëæ×Å Asynchronous JavaScript and XML (Ajax) ¸ÅÄ»ùÓÚ Web µÄ±à³ÌµÄ½»»¥ÐÔÌáÉýµ½Ò»¸öи߶ȣ¬JavaScript Ò²±äµÃÔ½À´Ô½ÖØÒª¡£ÔÚ³öÏÖ Ajax ֮ǰ£¬ËùÓзþÎñÆ÷¶Ë´¦Àí»òÊý¾Ý¿â·ÃÎʶ¼ÐèÒª “ˢД Õû¸öÒ³Ãæ»òͨ¹ýä¯ÀÀÆ÷³ÊÏÖÒ»¸öÐÂÒ³Ãæ¡£Õâ²»½ö¼õÂýÁËËٶȲ¢Ê¹Óû§¸Ðµ½¾ÚÉ¥£¬¶øÇÒ»¹ÀË·Ñ´ø¿íºÍ×ÊÔ´¡£
Ajax ±íʾ Asynchronous JavaScript and XML£¬µ«Êǽ«Æä³ÆΪ XML ÒѲ»ÔÙºÏÊÊ£¬ÒòΪ Ajax ÇëÇó¿ÉÒÔ·µ»Ø¶àÖÖ¸ñʽµÄÏìÓ¦£¬¶ø²»ÏÞÓÚ XML£¬ÀýÈç JSON (JavaScript Object Notation)¡£Ajax µÄ¹¤×÷·½Ê½ÊÇÔÊÐí JavaScript Òì²½Ìá½» HTTP ÇëÇóµ½ Web ·þÎñÆ÷£¬²¢ÇÒÔÚ²»Ë¢Ð»ò³ÊÏÖÐÂÒ³ÃæµÄÇé¿öϳÊÏÖÏìÓ¦¡£Ïà·´£¬¿ª·¢ÈËԱͨ³£Ê¹Óà DOM (Document Object Model) ²Ù×÷À´Ð޸IJ¿·Ö Web Ò³Ã棬ÏÔʾÆä±ä»¯»òÓÉ HTTP ÏìÓ¦·µ»ØµÄÊý¾Ý¡£
»ØÒ³Ê×
ʲôÊÇ JavaScript ¿ò¼Ü£¿
JavaScript ±¾Éí¾ÍÊÇÒ»ÖÖ¹¦ÄÜÇ¿´óµÄÓïÑÔ£¬Äú²»ÐèÒª¶îÍâµÄ¿ò¼Ü¾Í¿É´´½¨¸»»¥ÁªÍøÓ¦ÓóÌÐò£¨RIA£©¡£È»¶øʹÓà JavaScript ²¢²»ÊǼþÈÝÒ×µÄÊ£¬Ö÷ÒªÊÇÓÉÓÚÖ§³Ö¶à¸ö Web ä¯ÀÀÆ÷²úÉúµÄ¸´ÔÓÐÔ¡£Óë HTML ºÍ CSSÒ»Ñù£¬²»Í¬µÄä¯ÀÀÆ÷Óв»Í¬µÄ JavaScript ʵÏÖ¡£Èà JavaScript ´úÂëʵÏÖ¿çä¯ÀÀÆ÷¼æÈݼòÖ±ÊǸöجÃΡ£
JavaScript ¿ò¼Ü»ò¿âÊÇÒ»×éÄÜÇáËÉÉú³É¿çä¯ÀÀÆ÷¼æÈÝµÄ JavaScript ´úÂëµÄ¹¤¾ßºÍº¯Êý¡£Ã¿Ò»¸ö¿â¶¼ÔÚÖÚ¶àÁ÷ÐÐµÄ Web ä¯ÀÀÆ÷µÄÏÖ´ú°æ±¾ÉϽøÐÐÁË¿É¿¿µÄ²âÊÔ£¬Òò´Ë£¬Äú¿ÉÒÔ·ÅÐĵØʹÓÃÕâЩ¿ò¼Ü£¬ÄúµÄ»ùÓÚ JavaScrip
Ïà¹ØÎĵµ£º
window
window¶ÔÏóÊÇä¯ÀÀÆ÷»òÕß¿ò¼Ü×ÔÉí.top×ÜÊÇä¯ÀÀÆ÷,parentÊǸ¸¿ò¼Ü,self±íʾ×Ô¼º.
windowͨ³£¿ÉÒÔÊ¡ÂÔ.
´°¿Ú²Ù×÷: moveBy(dx, dy), moveTo(x, y),
resizeBy(dw, dh), resizeTo(w, h).
µ¼º½: window.open(url, frame
name, attribute). attribute¿ÉÒÔÊÇleft, top, height, width, resizable,
scrollable, too ......
±¾ÎĵÄÁ½¸öÄ¿µÄ£º
£¨1£©½éÉÜjavascriptÖеÄevalº¯ÊýµÄÓ÷¨
£¨2£©ÈçºÎÔÚº¯ÊýÄÚÖ´ÐÐÈ«¾Ö´úÂë
►ÏÈÀ´ËµevalµÄÓ÷¨£¬ÄÚÈݱȽϼòµ¥£¬ÊìϤµÄ¿ÉÒÔÌø¹ý¡£
evalº¯Êý½ÓÊÕÒ»¸ö²ÎÊýs£¬Èç¹ûs²»ÊÇ×Ö·û´®£¬ÔòÖ±½Ó·µ»Øs¡£·ñÔòÖ´ÐÐsÓï¾ä¡£Èç¹ûsÓï¾äÖ´Ðнá¹ûÊÇÒ»¸öÖµ£¬Ôò·µ»Ø´ËÖµ£¬·ñÔò·µ»Øundefined¡£
ÐèÒªÌرð×¢ÒâµÄÊǶÔÏóÉùÃ÷Óï· ......
<iframe width='100%' height='100%' name='boot' id='boot' src='' frameborder='0' scrolling='no'></iframe>
<SCRIPT LANGUAGE="JavaScript">
<!--
var iframe = window.frames['boot'];
iframe.document.open();
iframe.document.write('<!DOCTY ......
//1.Àà
function Test(id)
{
this.id=id;
this.method=function()
{
//´úÂë
};
}
......
window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}
onbeforeunload ʼþ²Î¿¼µØÖ·
http://msdn.microsoft.com/en-us/ ......