JavaScript¶ÁÈ¡TxtÎļþ
JavaScript¶ÁÈ¡TxtÎļþ
<html>
<head>
<title>new page</title>
<script>
GetHeader(src) {
var ForReading=1;
var fso=new ActiveXObject("Scripting.FileSystemObject");
var f=fso.OpenTextFile(src,ForReading);
return(f.ReadAll());
}
var arr=GetHeader("C:\\a.txt").split("\r\n");
for(var i=0;i<arr.length;i++){
alert("µÚ"+(i+1)+"ÐÐÊý¾ÝΪ:"+arr[i]);
}
</script>
</head>
<body>
</body>
</html>
Ïà¹ØÎĵµ£º
ÔÚjavascript¿ØÖÆdivÖ®¼äµÄÍâ±ß¾àʱ£¬´úÂëдµ½
document.getElementById("").style.marginTop=20;
Õâ¸öÔÚIEä¯ÀÀÆ÷ÖпÉÒÔ£¬µ«ÊÇÔÚchromeÖоͲ»ÐУ¬Õâ¸öÎÊÌâÊÇÓ¦¸Ã
document.getElementById("").style.marginTop="20px";
¸÷¸öä¯ÀÀÆ÷Öв»Í¬µÄÎÊÌâÒªÇ󲻵ȶԴý£¬ÕâЩÌìѧÁËdiv+cssÔÚÉèÖø÷¸öä¯ÀÀÆ÷ÊDz»Í¬µÄÅäÖã¬ÒªÕë¶Ôÿ¸ö ......
ÔÚ×öÒ»¸öÏîÄ¿ÖУ¬½Ó´¥µ½ÁËJavaScript£¬Ö÷ÒªÊǵã»÷Ò»¸ö²éѯ°´Å¥È»ºóµ¯³öÒ»¸öÍøÒ³¶Ô»°¿ò£¬µ±ÔÚ¶Ô»°¿òÖÐÊäÈë²éѯÌõ¼þ£¬µã»÷È·¶¨ºóÓÖ·µ»Øµ½ÔÀ´Ò³Ãæ,µÃ³ö²éѯ½á¹û¡£
Ò³ÃæÈçͼ£º
ÔÚǰ̨¼ÓÁËÒ»¸öÒþ²ØµÄDIV£¬ÀïÃæ·ÅÈëÁ½¸ö¿Ø¼þ¡£ÈçÏ£º
<div style="display:none">
< ......
¶¨ÒåºÍÓ÷¨
prompt() ·½·¨ÓÃÓÚÏÔʾ¿ÉÌáʾÓû§½øÐÐÊäÈëµÄ¶Ô»°¿ò¡£
Óï·¨
prompt(text,defaultText)
²ÎÊýÃèÊö
text
¿ÉÑ¡¡£ÒªÔÚ¶Ô»°¿òÖÐÏÔʾµÄ´¿Îı¾£¨¶ø²»ÊÇ HTML ¸ñʽµÄÎı¾£©¡£
defaultText
¿ÉÑ¡¡£Ä¬ÈϵÄÊäÈëÎı¾¡£
˵Ã÷
Èç¹ûÓû§µ¥»÷Ìáʾ¿òµÄÈ¡Ïû°´Å¥£¬Ôò·µ»Ø null¡£Èç¹ûÓû§µ¥»÷È·Èϰ´Å¥£¬Ôò·µ»ØÊäÈë×ֶε±Ç°Ï ......
ÕýÔÚ¿´¡¡javascript¸ß¼¶³ÌÐòÉè¼Æ¡¡,ÆäÖйØÓÚ·Ö×éÀïÃæµÄÒ»¾ä´úÂë²»ÊÇÌ«Àí½â:
ͨ¹ýÅäºÏʹÓÃString¶ÔÏóµÄreplace()·½·¨¼°·´ÏòÒýÓ㬾ͿÉÒÔ¶¨Òå×Ô¼ºµÄtrim()·½·¨:
String.prototype.trim = function() {
var reExtraSpace = /^\s+(.*?)\s+$/;
return this.replace(reExtraSpace,"$1");
}
Ò»¿ªÊ¼ÔõôҲ²» ......