JavaScript¶¯Ì¬Ìí¼ÓDOMÔªËØ×ܽá
ÕâÁ½Ì쿪ʼд¹Å´úµØͼµÄGISÍøÕ¾£¬Ëµ°×Á˾ÍÊÇÓùŴúµØͼµÄÄÚÈÝЧ·ÂɽկһϹȸèµØͼ¡£
JSÕⶫÎ÷ºÜ¾ÃûдÁË£¬ÓÐЩ¸ÅÄîÒ²ºÜÄ£ºý£¬µ¼ÖÂÍê³É·Ö¿éÍ϶¯¼ÓÔصŦÄܾͻ¨Á˺öàʱ¼ä¡£
Ö÷ÒªÎÊÌâÊdzöÔÚÍ϶¯Ê±¶ÔÔªËØÄÚÈݵĶ¯Ì¬ÐÞ¸ÄÉÏ£¬×ܽáÏ¡£
ͨ¹ýJS½Å±¾¶¯Ì¬ÐÞ¸ÄDOMÔªËØÄÚÈÝͨ³£ÓÐÁ½ÖÖ·½·¨£º
1. ͨ¹ýDOM±ê×¼½Ó¿Ú´´½¨ÔªËØ
var newNode = document.createElement("div");
mapDiv.insertBefore(newNode, mapDiv.getElementsByTagName("div")[0]);
2. ͨ¹ýÐÞ¸ÄÔªËصÄinnerHTMLÊôÐÔÀ´¸Ä±äÄÚÈÝ
mapDiv.innerHtml += "<div class='piece' style='top:"+(i*256+parseInt(blockArray[0][0].style.top))+"px; left:"+(parseInt(blockArray[0][0].style.left)-256)+"px; background-image:url(\"assets/full_map/x="+x+"&y="+(y+i>15?y+i-16:y+i)+"&z=4.png\")'></div>";
Á½ÖÖ·½·¨¶¼¿ÉÒԸıäÔªËصÄÄÚÈÝ£¬µ«ÊÇÂÔÓв»Í¬¡£
ÐÞ¸ÄinnerHTMLÊôÐԵĻ°£¬ÏµÍ³»á¶ÔÄÚÈݽøÐÐÖع¹£¬ÖØÐÂÉú³ÉDOMÔªËØ£¨ÐµĵØÖ·£©£¬¼´Ê¹Ö»ÊÇÔÚ×îºó×·¼ÓÁËÒ»¸öÔªËØ£¬¶øDOM API²Ù×÷Ôò²»»á¡£
¾Ù¸öÀý×Ó£¬ÓÃÊý×é±£´æDIV1ÖеÄËùÓÐÔªËØ(subDiv1, subDiv2, subDiv3.......)µ±ÐÞ¸ÄinnerHTML×·¼ÓÒ»¸ösubDivnµÄʱºò£¬×·¼ÓÍêµÄDOMÔªËØÓëÊý×éÖеIJ»ÔÙ¶ÔÓ¦ÁË£¬ÒòΪÖØлæÖÆÁË£¬ÔªËØÓÐÁËеĵØÖ·£¨Êý×é´æµÄ½ö½öÊǵØÖ·£©¡£¶øDiv1.appendChild(subDivn)Ö®ºó£¬Êý×éÓëÄÚ²¿ÔªËØÈÔÈ»±£³Ö¶ÔÓ¦¹Øϵ¡£
ËÙ¶ÈÉÏÀ´ËµµÄ»°DOM½Ó¿ÚµÄËٶȻáÏà¶Ô½ÏÂý£¬¶øÐÞ¸ÄinnerHTML»òÕßÊÇwrite()·½·¨»áÃ÷ÏԽϿ졣
Ïà¹ØÎĵµ£º
<html>
<head>
<title>²âÊÔÊäÈë×Ö·û</title>
<script language=javascript>
String.prototype.lenB =function(){
return this.replace(/[^\x00-\xff]/g,"**").length;
}
function a() ......
×î½üµÄÏîÄ¿¿ª·¢ÖÐ Óöµ½Ò»Ð©ÐèÒª¸ù¾Ý¾ßÌåÇé¿ö¶¯Ì¬Ìí¼ÓjavaScript½Å±¾£¬È»ºóÖ´Ðнű¾ ÓÚÊÇÊÕ¼¯ÁËһϣº
1 ÔڿؼþµÄ°ó¶¨Ê¼þÖÐÌí¼Ó½Å±¾ È磺ÔÚgridview¿Ø¼þµÄrowdatabindʼþÖпÉÒÔʵÏÖ Ö¸ÕëµÄÑ¡ÖÐÐв»Í¬É«ÏÔʾ ¿ÉÌí¼Ó½Å±¾
protected void gvEngineerRepairState_RowDataBound(object sender, GridViewRowEventArgs e ......
--------------------------------------------------------------------------------
<body>
<mce:script type="text/javascript"><!--
document.write("Èç¹ûÏÔʾÁËÕâ¶ÎÎÄ×Ö£¬ÄÇôÄúµÄä¯ÀÀÆ÷Ö§³Ö JavaScript£¡")
// --></mce:script>
<noscript>No JavaScript support!</noscript&g ......
1
¡¢Àí½âdocument.all
[]
¡¡¡¡´ÓIE4¿ªÊ¼IEµÄobject
model²ÅÔö¼ÓÁËdocument.all
[],À´¿´¿´document.all
[]µÄDescription:
Array
of all HTML tags in the document.Collection of all elements contained by the
object.
¡¡¡¡Ò²¾ÍÊÇ˵document.all
[]ÊÇÎĵµÖÐËùÓбêÇ©×é³ÉµÄÒ»¸öÊý×é±äÁ¿£¬°üÀ¨ÁËÎĵµ¶ÔÏóÖÐËùÓ ......
! È¥³ý×Ö·û´®Á½¶Ë¿Õ¸ñµÄ´¦Àí
¡¡¡¡Èç¹û²ÉÓô«Í³µÄ·½Ê½,¾ÍÒª¿ÉÄܾÍÒª²ÉÓÃÏÂÃæµÄ·½Ê½ÁË
¡¡¡¡//Çå³ý×ó±ß¿Õ¸ñ
¡¡¡¡function js_ltrim(deststr)
¡¡¡¡{
¡¡¡¡if(deststr==null)return "";
¡¡¡¡var pos=0;
¡¡¡¡var retStr=new String(deststr);
¡¡¡¡if (retStr.lenght==0) return retStr;
¡¡¡¡while (retStr.substring(pos, ......