Javascript: onresize
ä¯ÀÀÆ÷£ºIE 8¡¢FF 3.6¡¢Chrome 4.0¡¢Safari 4.0¡¢Opera 10.1
½öÓÐIEä¯ÀÀÆ÷Ö§³ÖHTMLElement.onresize£¨±ÈÈçbody.onresize£©
ÆäËüä¯ÀÀÆ÷Ö»Ö§³Öwindow.onresize
ÏÈ˵IEµÄHTMLElement.onresize
ʹÓÃÇ°ÇëÈ·¶¨ÄãµÄÐÄÔ༰ѪѹÕý³££¬Èç¹ûÄ㶨ÒåÁË
body.onresize = function(){……}»òÕßhtml.onresize = obj.fun;
Äã²Â²ÂthisÖ¸ÕëÊÇË£¿²»ÊÇbody£¬²»ÊÇhtml£¬²»ÊÇobj£¬¶øÊÇwindow£¡
ÕâÑùÇå¿öÏÂÈç¹û£º
function fun(){
……
};
html.onresize = fun;
body.onresize = fun;
document.getElementById("id").onresize = fun;
ÒÔÉÏ´úÂëÍêÈ«¿ÉÓã¬Ö»ÊÇfunÖ´ÐÐʱ£¬Äã¸ù±¾²»ÖªµÀÊÇÄĸöÔªËؼ¤·¢µÄ¡£Ê²Ã´£¿Äã˵event¶ÔÏñÀï»á²»»áÓм¤·¢µÄÔªËØ£¿¿Ï¶¨µÄ˵£ºÃ»ÓУ¡
ºÃÁË£¬ÎÒÃÇ·ÅÇáËÉ£¬Ã»°ì·¨¾Íû°ì·¨°É¡£´ó²»ÁËÎҾͲ»¹ÜÊÇ˼¤·¢µÄÈ«¶¼´¦ÀíÒ»±é¡£²»¹ý»¹ÊÇÏÈ¿´ÏÂÃæµÄ´úÂ룺
function addresize(element){
element.onresize = function(){
……
};
};
addresize(body);
addresize(html);
addresize(#id);
Äã²Â²ÂÔÚonresizeÖ´ÐÐʱµÄthisÊÇË£¿±ðÏëÁË£¬»¹ÊÇwindow£¡
ÁéÒìµÄÊÂÇé·¢ÉúÁË£¬ÔÚÊ¡ÂԺŵĴúÂëÖÐÄã¿ÉÒÔʹÓÃelement±äÁ¿£¡Ò²¾ÍÊÇaddresizeµÄ²ÎÊý£¬Õâ¸ö²ÎÊýÊÇʼþ¼¤·¢ÔªËØ¡£
ΪÕâ¸öÊÂÎÒÔÎÁ˺ü¸Ì죬µ½ÏÖÔÚ¶¼Ã»ÏëÃ÷°×Õâ¸öÓï·¨¹æÔò£¬µ±×÷Ò»¸öÌØÊâÓ÷¨°É¡£
ÏÂÃæ˵window.onresize
ÔÚIEÖÐÕâ¸öʼþºÜºÃÓ㬵±´°¿ÚÈÝÁ¿´óС·¢Éú±ä»¯Ê±¾Í»á¼¤·¢£¡£¨×¢ÒâºÚÌå×Ö£©
ÔÚÆäËüä¯ÀÀÆ÷ÖоÍÓÐÎÊÌâÁË£¬Ëü½öÔÚ´°¿Ú´óС·¢Éú±ä»¯Ê±¼¤·¢¡£
ÕâÀï¾ÍÓÐÇø±ðÁË£º
µ±ÎÒÏëÈÃij¸öÔªËسäÂúÕû¸ö´°¿Ú£¬ÕâÑùµÄ»°ÔÚwindow.onresizeʱ¾ÍÐèÒª¸Ä±äËüµÄstyle.width/height
ÔÚIEÖÐûÓÐÈκÎÎÊÌ⣬ÆäËüÓÎÀÀÆ÷ÔÚËõСʱ¾Í³öÏÖÎÊÌâÁË£º
Õû¸öʼþµÄÁ÷³ÌÊÇÕâ¸öÑù×ӵģº
1¡¢window¸Ä±ä´óС£¬ÕâÀïÌØÖ¸ËõС¡£
2¡¢ä¯ÀÀÆ÷·¢ÏÖÈÝÄɲ»ÏÂÄÚÈÝ£¬¸øhtmlÌí¼ÓÁ˹ö¶¯Ìõ£¬¿ÉÊÓÇøÓò¸üСÁË¡£
3¡¢ä¯ÀÀÆ÷¼¤·¢ÁËwindow.onresizeʼþ´úÂë¡£ÄãÔÚÕâÀï¸ü¸ÄÁËÔªËصĴóС¡£
4¡¢ä¯ÀÀÆ÷·¢ÏÖ¿ÉÒÔÈÝÄÉÏÂÄÚÈÝÁË£¬È¡ÏûÁ˹ö¶¯Ìõ¡£
5¡¢IEÔÚ´ËʱÔٴμ¤·¢onresize¡¢ÆäËüä¯ÀÀÆ÷ÂÔ¹ý´Ë²½
Õâʱ³ýIEÍ⣬ÄãµÄÔªËØ»áÉÙÒ»¸ö¹ö¶¯ÌõµÄ´óС¡£
½â¾ö·½°¸£º
³ýÁËIEÖ®ÍâµÄä¯ÀÀÆ÷ÇëÁ¬ÐøÉèÖÃÁ½´Î´óС¡£Ã¿´Î¶¼ÊÇÈ¡body.client/offset´óС¾ÍÐÐÁË¡£
Ïà¹ØÎĵµ£º
ÏÂÃæÊÇÊ®¸ö×îÅ£µÄÒ²ÊÇ×îÁ÷ÐеÄJavascript¿ò¼Ü¡£ËüÃÇÍêÈ«¿ÉÒÔµ£ÈÎÄ¿Ç°ÊÀ½çÉϼ¸ºõËùÓÐһЩºÍAjax¼¼ÊõÏà¹ØµÄºÍͼÐνçÃæÏà¹ØµÄÒ»Çй¦ÄÜ¡£
jQuery
http://jquery.com/
Èç¹û½ñÌìÄ㻹²»ÖªµÀjQueryµÄ»°£¬ÄÇô×÷Ϊһ¸ö³ÌÐòÔ±Äã¿ÉÄÜÕæµÄÊÇ´Ó»ðÐÇÀ´µÄÁË¡£Õâ¿ÖÅÂÊÇAjaxÖÐÓ¦ÓÃ×î¹ãµÄ¿ò¼Ü¡£°üÀ¨ÁËÐí¶àºÜ²»´íµÄUI×é¼þ£¬×ö³öÍø ......
JavaScript ¿ÉËãÊÇÊÀ½çÉÏ×îÁ÷Ðеıà³ÌÓïÑÔ£¬ËüÔø±» Web ¿ª·¢Éè¼ÆʦÌùÉÏجÃεıêÇ©£¬ËäÈ»ÕæÕýµÄجÃÎÆäʵÊÇ DOM
API£¬Õâ¸ö±»´óÁ¿µÄ¿ª·¢ÓëÉè¼ÆʦËæÊÖÄéÀ´ÔöÇ¿ËûÃÇµÄ Web Ç°¶ËµÄ½Å±¾ÓïÑÔ£¬Èç½ñÔ½À´Ô½±»ÖØÊÓ£¬ËäÔòÈç´Ë£¬JavaScript
ÈÔȻӵÓкܶàÈÃÈ˷ѽâµÄ¶«Î÷¡£
1. ËüÒÔ Java ÃüÃû£¬µ«²¢²»ÊÇ Java
Ëü×î³õ½Ð Mocha£¬ ½ÓןÄà ......
Ê×ÏÈÔÚbodyÖмÓÈëÒÔÏÂHTMLÄÚÈÝ£º
<div id="panel">
<div id="top">
<ul id="menu">
<li id="1">Home</li>
&nbs ......
//´´½¨Ò»¸öеÄÔªËؽڵ㣬ԪËØÃûʹÓÃsTagName¶¨Òå
oElementNode = document.createElementNode(sTagName);
//´´½¨Ò»¸öеĽڵ㣬½ÚµãÃûʹÓÃsTextValue¶¨Òå
oTextNode = document.createTextNode(sTextValue);
//ΪԪËظ³Ò»¸öеÄÊôÐÔ£¬ÊôÐÔÃûʹÓÃsName
oAttribute = document.createAttribute(sName);
//´´½¨Ò»¸öÐ嵀 ......
<script language="JavaScript">
<!--
//ͼƬ°´±ÈÀýËõ·Å
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
//²ÎÊý(ͼƬ,ÔÊÐíµÄ¿í¶È,ÔÊÐíµÄ¸ß¶È)
var image=new Image();
image.src=ImgD.src; ......