JavaScript³£Ó÷½·¨×ܽᗗһЩº¯Êý
¸ù¾ÝÉí·ÝÖ¤ºÅÂëÈ¡µÃÉúÈÕÓëÐԱ𣬲¢ÅжÏ18λÉí·ÝÖ¤µÄÕýÈ·Óë´íÎó:
function showBirthday(val){
var birthdayValue;
if(15==val.length){//15λÉí·ÝÖ¤ºÅÂë
birthdayValue = val.charAt(6)+val.charAt(7);
if(parseInt(birthdayValue)<10){
birthdayValue = '20'+birthdayValue;
}else{
birthdayValue = '19'+birthdayValue;
}
birthdayValue=birthdayValue+'-'+val.charAt(8)+val.charAt(9)+'-'+val.charAt(10)+val.charAt(11);
if(parseInt(val.charAt(14)/2)*2!=val.charAt(14))
document.all.sex.value='ÄÐ';
else
document.all.sex.value='Å®';
document.all.birthday.value=birthdayValue;
}
if(18==val.length){//18λÉí·ÝÖ¤ºÅÂë
birthdayValue=val.charAt(6)+val.charAt(7)+val.charAt(8)+val.charAt(9)+'-'+val.charAt(10)+val.charAt(11)+'-'+val.charAt(12)+val.charAt(13);
if(parseInt(val.charAt(16)/2)*2!=val.charAt(16))
document.all.sex.value='ÄÐ';
else
document.all.sex.value='Å®';
if(val.charAt(17)!=IDCard(val)){
document.all.idCard.style.backgroundColor='#ffc8c8';
}else{
document.all.idCard.style.backgroundColor='white';
}
document.all.birthday.value=birthdayValue;
}
}
// 18λÉí·ÝÖ¤ºÅ×îºóһλУÑé
function IDCard(Num)
{
if (Num.length!=18)
return false;
var x=0;
var y='';
for(i=18;i>=2;i--)
x = x + (square(2,(i-1))%11)*parseInt(Num.charAt(19-i-1));
x%=11;
y=12-x;
if (x==0) y='1';
if (x==1) y='0';
if (x==2) y='X';
return y;
}
// ÇóµÃxµÄy´Î·½
function square(x,y)
{
var i=1;
for (j=1;j<=y;j++)
i*=x;
return i;
}
Éí·ÝÖ¤<input type="text" name="idCard">
ÐÔ±ð<input type="text" name="sex">
ÉúÈÕ<input type="text" name="birthday">
»ñÈ¡Ò³ÃæÖпؼþµÄID:(²é´íʱ¿ÉÄÜÓÐÓÃ)
function clk()
{
document.all('TextBox1').value=event.srcElement.id;
}
document.onclick=clk;
¡¡B.27 string¶ÔÏó
¡¡¡¡Ëü²»ÊÇÁíÒ»¸ö¶ÔÏóµÄÊôÐÔ,¶øÊÇÒ»¸öÄÚÖöÔÏó,¼´Ò»´®×Ö·û×Ö·û´®ÊäÈë½Å±¾ÖÐʱ±ØÐëλÓÚÒýºÅÄÚ¡£
¡¡¡¡ÊôÐÔ
¡¡¡¡length ×Ö·û´®ÖеÄ×Ö·û¸öÊý
¡¡¡¡·½·¨
¡¡¡¡anchor() ÓÃÀ´°Ñ×Ö·û´®×ª»»µ½htmlêµã±ê¼ÇÄÚ(<A NAME=&
Ïà¹ØÎĵµ£º
Definition and Usage
¶¨ÒåÓëÓ÷¨The constructor property is a reference to the function that created an object.
constructorÊôÐÔÊÇËù½¨Á¢¶ÔÏóµÄº¯Êý²Î¿¼Syntax
Óï·¨object.constructor
Example 1
¾ÙÀý
In this example we will show how to use the constructor property:
ÔÚÕâ¸ö¾ÙÀýÖÐÎÒÃǽ«Õ¹Ê¾ÈçºÎʹÓÃcons ......
1.document.write( " "); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document- >html- >(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window- >(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËØµÄÃû³ÆºÍÖµ:document.getElementById( "±íµ¥ÖÐÔªËØµÄID號 ").name(»òvalue)
6.Ò»¸ö ......
ÔÚJavaScriptÖпÉÒÔ´´½¨ÈýÖÖÏûÏ¢¿ò£º¾¯¸æ¿ò¡¢È·ÈÏ¿ò¡¢Ìáʾ¿ò
¾¯¸æ¿ò¾³£ÓÃÓÚÈ·±£Óû§¿ÉÒԵõ½Ä³Ð©ÐÅÏ¢¡£µ±¾¯¸æ¿ò³öÏÖºó£¬Óû§ÐèÒªµã»÷È·¶¨°´Å¥²ÅÄܼÌÐø½øÐвÙ×÷¡£
Óï·¨£º
alert("Îı¾")
È·ÈÏ¿òÓÃÓÚʹÓû§¿ÉÒÔÑéÖ¤»òÕß½ÓÊÜijЩÐÅÏ¢¡£µ±È·ÈÏ¿ò³öÏÖºó£¬Óû§ÐèÒªµã»÷È·¶¨»òÕßÈ¡Ïû°´Å¥²ÅÄܼÌÐø½øÐвÙ×÷¡£Èç¹ûÓû§µã»÷È·ÈÏ£¬Ä ......
½üÈÕ£¬ÖªÃû¼¼Êõ¿ª·¢ÍøÕ¾SYS-CON ýÌåÁгöÊ®¸öÓ¦ÓÃ×î¹ãµÄjavascript¿ò¼Ü¡£ÎÄÕÂ˵£¬Javascript¿âÒѾ³ÉΪÉè¼ÆÓÅÐãÍøÕ¾µÄ»ù´¡£¬µ±½ñ¼¸ºõËùÓÐÕ¾µã¶¼´øÓÐJavascript»òAjaxÔªËØ¡£ÔÚWeb2.0¿ª·¢´ó³±ÖУ¬ËüÒ²ÐíÊÇ×î¹Ø¼üµÄÒªËØ¡£
ÒÔÏÂÊ®´óJavascript¿ò¼Ü£¬Äã³£ÓÃÆäÖеö?
1. script.aculo.us (http://script.aculo.us/)
......
ÍøÒ³³£ÓÃС¼¼ÇÉ
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡Ïûѡȡ¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return fa ......