Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javaScriptͨÓÃÊý¾ÝÀàÐÍУÑé

  /** 
* È¡µÃ×Ö·û´®µÄ×Ö½Ú³¤¶È 
*/ 
´úÂë
function strlen(str)
{
var i;
var len;

len = 0;
for (i=0;i<str.length;i++)
{
if (str.charCodeAt(i)>255) len+=2; else len++;
}
return len;
}


/* 
* ÅжÏÊÇ·ñΪÊý×Ö£¬ÊÇÔò·µ»Øtrue,·ñÔò·µ»Øfalse 
*/ 
´úÂë
function f_check_number(obj)
{
if (/^\d+$/.test(obj.value))
{
return true;
}
else
{
f_alert(obj,"ÇëÊäÈëÊý×Ö");
return false;
}
}


/* 
* ÅжÏÊÇ·ñΪ×ÔÈ»Êý£¬ÊÇÔò·µ»Øtrue,·ñÔò·µ»Øfalse 
*/ 
´úÂë
function f_check_naturalnumber(obj)
{
var s = obj.value;
if (/^[0-9]+$/.test( s ) && (s > 0))
{
return true;
}
else
{
f_alert(obj,"ÇëÊäÈë×ÔÈ»Êý");
return false;
}
}


/* 
* ÅжÏÊÇ·ñΪÕûÊý£¬ÊÇÔò·µ»Øtrue,·ñÔò·µ»Øfalse 
*/ 
´úÂë
function f_check_integer(obj)
{
if (/^(\+|-)?\d+$/.test( obj.value ))
{
return true;
}
else
{
f_alert(obj,"ÇëÊäÈëÕûÊý");
return false;
}
}


/* 
* ÅжÏÊÇ·ñΪʵÊý£¬ÊÇÔò·µ»Øtrue,·ñÔò·µ»Øfalse 
*/ 
´úÂë
function f_check_float(obj)
{
if (/^(\+|-)?\d+($|\.\d+$)/.test( obj.value ))
{
return true;
}
else
{
f_alert(obj,"ÇëÊäÈëʵÊý");
return false;
}
}

/* 
* УÑéÊý×ֵij¤¶ÈºÍ¾«¶È 
*/ 
´úÂë
function f_check_double(obj){
var numReg;
var value = obj.value;
var strValueTemp, strInt, strDec;
var dtype = obj.eos_datatype;
var pos_dtype = dtype.substring(dtype.


Ïà¹ØÎĵµ£º

JavaScript ¹¹½¨ÀàºÍ´´½¨¶ÔÏóµÄ·½Ê½

1>¹¤³§º¯ÊýÀ´´´½¨¶ÔÏó(Factory)
     function createCar(){
var obj = new Object;
obj.name = "BWM";
obj.show = function(){
alert(this.name);
}
return obj;
}
var car1 = createCar();
var car2 = createCar();
car1.show();
car2.show();
2>¹¹Ô캯Êý´´½¨¶ÔÏó ......

JavaScriptÏÔʾʱ¼ä

Õâ¸öÎÊÌâºÜ¼òµ¥£¬Ö÷ÒªÓÐÏÂÃ漸¸ö֪ʶµã£º
£¨1£©       È¡µÃʱ¼ä£ºvar d=new Date();var time=d.toLocaleString()
£¨2£©       ÏÔʾÔÚÍøÒ³ÉÏ£¬¼ÙÉèдÔÚÒ»¸ö<span>ÖУ¬ÇÒ¸Ã<span>µÄidΪshowTime:
document.getElementById("showTime").innerHTML ......

JavaScript summary

1. ÍøÒ³ÖⶻñJavaScript´íÎóµÄÁ½ÖÖ·½·¨£º
ʹÓà onerror ʼþÊÇÒ»ÖÖÀÏʽµÄ±ê×¼µÄÔÚÍøÒ³Öⶻñ Javascript ´íÎóµÄ·½·¨
throw ÉùÃ÷µÄ×÷ÓÃÊÇ´´½¨ exception£¨Òì³££©¡£Äã¿ÉÒÔ°ÑÕâ¸öÉùÃ÷Óë try...catch ÉùÃ÷ÅäºÏʹÓã¬ÒÔ´ïµ½¿ØÖƳÌÐòÁ÷²¢²úÉú¾«È·´íÎóÏûÏ¢µÄÄ¿µÄ¡£
2.Á½¸öJavaScriptÎļþ¼äº¯ÊýµÄµ÷ÓÃ
http://space.flash8.net ......

¶àä¯ÀÀÆ÷¼æÈÝÐÔÎÊÌâ¼°½â¾ö·½°¸Ö®Javascriptƪ

 
ʱ¼ä: 2009-9-02 - ·ÖÀà: Html+CSS, JavaScript - ÆÀÂÛ: 0 - ÔĶÁ: 70 ´Î
CSS¸úJavaScript¿ª·¢ÖУ¬×îÁî´ó¼ÒÍ·ÌÛµÄÎÊÌâ¾ÍÊÇä¯ÀÀÆ÷¼æÈÝÐÔÁË£¬ËäÈ»ºÜ¶àÎÄÕÂÓÐÕâ·½ÃæµÄÎÄÕ£¬µ«ÒÀÈ»Èúܶ࿪·¢ÈËÔ±ÔÎͷתÏò£¬¶øÇÒÒ²²»¹»È«Ãæ¡£ÕâƪÎÄÕ£¬½«È«ÃæÊÕ¼¯cssºÍjavascriptÔÚ¸÷ÖÖä¯ÀÀÆ÷ϵļæÈÝÐÔ±¨¸æ£¬Ò²ÆÚ´ý¸÷λ²»¶Ï²¹³ä¡£
Ó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ