JavaScriptÑéÖ¤ÉÏ´«Îļþ¸ñʽ¼°´óС
ÔÚÉÏ´«²Ù×÷ÖУ¬¾³£»áÓöµ½ÒªÇóÖ¸¶¨ÉÏ´«ÎļþµÄ¸ñʽ£¬ÏÂÃæµÄʵÀýÊÇÔÚ¿Í»§¶Ëͨ¹ýJavaScriptÑéÖ¤ÉÏ´«Í¼Æ¬¸ñʽΪjpg/gif/png
<html>
<head>
<mce:script language="JavaScript" type="text/JavaScript"><!--
var img=null;
function checkPic(picForm){
var location=picForm.pic.value;
if(location==""){
alert("ÇëÏÈÑ¡ÔñͼƬÎļþ");
return false;
}
var point = location.lastIndexOf(".");
var type = location.substr(point);
if(type==".jpg"||type==".gif"||type==".JPG"||type==".GIF"||type==".PNG"||type==".png"){
img=document.createElement("img");
img.src=location;
if(img.fileSize>102400){
alert("ͼƬ³ß´çÇë²»Òª´óÓÚ100KB");
return false;
}else
return true;
}
else{
alert("Ö»ÄÜÊäÈëjpg»òÕßgif¸ñʽµÄͼƬ");
return false;
}
return true;
}
function changesrc(){
yourpic.src=picForm.pic.value;
}
// --></mce:script>
</head>
<body>
<table width="100%" border="0">
<tr>
<td>
<div align="center"><img border="1" id="yourpic"
onload="javascript:if(this.width>175)this.width=175;if(this.height>150)this.height=150;">
</div>
</td>
</tr>
<form name="picForm" action="#" method="post"
enctype="multipart/form-data" onsubmit="return checkPic(picForm);">
<tr>
<td>
<div align="center"><input type="file" name="file" size="10"
id="pic" onchange="changesrc()"/></div>
</td>
</tr>
<tr>
<td>
<div align="center"><input type="submit" value="ÉÏ´«ÕÕƬ" /></div>
</td>
</tr>
</table>
</body>
</html>
ÕâÖÖÅжÏÖ»ÊÇÒ»¸ö³õ²½µÄÅжϣ¬µ±ÉÏ´«ÎļþΪÐ޸ĸñʽµÄÇ
Ïà¹ØÎĵµ£º
function getCookies(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return '';
}
function setCookie(name, value, expires, path, domain, secure)
{
var liveDate = new Date();
expires = l ......
Èç¹ûÄú»¹Ã»ÓÐÔĶÁ¡¶JavaScriptµ÷ÊÔ¼¼ÇÉÖ®£º¿ìËÙ¶¨Î»¡·£¬½¨ÒéÏÈ¿´¿´ÄÇƪ¡£Ëµ²»¶¨£¬ÓÿìËÙ¶¨Î»¾ÍÄܽâ¾öÎÊÌâÁË£¬ºÇºÇ¡£Õâ´ÎÎÒ»á×ܽá¼Ç¼һ϶ϵãµ÷ÊԵıʼǣ¬Ï£ÍûÒ²¶Ô´ó¼ÒÓÐÓ㬻¶Ó²¹³ä½»Á÷£¡
Ê×ÏÈ£¬ÔÚ¸÷¸öä¯ÀÀÆ÷ÖУ¬¶Ïµãµ÷ÊÔÖ§³ÖµÄ×îºÃµÄµ±È»ÊÇFirefox£¬Firefox²»½ö¿ÉÒÔʹÓÃFirebugµ÷ÊÔÒ³Ãæjs½Å±¾£¬»¹¿ÉÒÔÓø߼¶µ÷ÊÔ¹¤¾ßÀ ......
ÔÎijö´¦: http://www.dnew.cn/post/196.htm
ÏÈ¿´ÏÂÏÂÃ漸ÖÖд·¨
1.function f(x){return x*x;};f(x);
2.(function(x){return x*x;})(x);
3.(function(x){return x*x;}(x));
µÚÒ»ÖÖÎÒÃÇÓ¦¸Ã¶¼ºÜÊìϤÁË£¬ÕâÊÇÎÒÃǾ³£Ê¹ÓõÄд·¨¡£µÚ¶þµÚÈýÖÖ¶¼ÊÇÄäÃûº¯ÊýµÄд·¨¡£
------------------------------------------------ ......
ÐÞ¸ÄÑ»·µÄÖ´Ðз½Ê½
for(var i=0;i<element.childNodes.length;i++){
Ö´ÐдúÂë
}
ÕâÖÖ·½Ê½Ã¿´ÎÑ»·¶¼ÒªÈ¡element.childNodes.lengthµÄÖµ£¬Ó¦¸Ã¸ÄΪÈçϵÄ
var n£½element.childNodes.length
for(var i=0;i<n;i++){
Ö´ÐдúÂë
}
2£ºÐÞ¸Ädom²Ù×÷µÄ´ÎÊý
domÅúÁ¿²åÈëÒ»ÅúÀàËƵĽڵ㲻ÈçÏȹ¹ÔìÒ»¸ö¶ÔÏó£¬ ......