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=&
Ïà¹ØÎĵµ£º
Ò»¡£È¡±í¸ñ¶ÔÏó
var getTable= document.getElementById("tabHeTong");
¶þ¡£²åÈëÐÐ
var oTR = getTable.insertRow();//ÐÂÔöÒ»ÐÐ
Èý¡£Ä³ÐмÓÈëÁÐ
var oTDa = oTR.insertCell();//ÐÂÔöÒ»ÁÐ
var oTDb = oTR.insertCell();//ÐÂÔö¶þÁÐ
var oTDc = oTR.insertCell();//ÐÂÔöÈýÁÐ
ËÄ¡£É¾³ýÐУº
getTable. ......
¶ÔÏóÊôÐÔ:
document.title //ÉèÖÃÎĵµ±êÌâµÈ¼ÛÓÚHTMLµÄ<title>±êÇ©
document.bgColor //ÉèÖÃÒ³Ãæ±³¾°É«
document.fgCol ......
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 ......
ÔÚJavaScriptÖпÉÒÔ´´½¨ÈýÖÖÏûÏ¢¿ò£º¾¯¸æ¿ò¡¢È·ÈÏ¿ò¡¢Ìáʾ¿ò
¾¯¸æ¿ò¾³£ÓÃÓÚÈ·±£Óû§¿ÉÒԵõ½Ä³Ð©ÐÅÏ¢¡£µ±¾¯¸æ¿ò³öÏÖºó£¬Óû§ÐèÒªµã»÷È·¶¨°´Å¥²ÅÄܼÌÐø½øÐвÙ×÷¡£
Óï·¨£º
alert("Îı¾")
È·ÈÏ¿òÓÃÓÚʹÓû§¿ÉÒÔÑéÖ¤»òÕß½ÓÊÜijЩÐÅÏ¢¡£µ±È·ÈÏ¿ò³öÏÖºó£¬Óû§ÐèÒªµã»÷È·¶¨»òÕßÈ¡Ïû°´Å¥²ÅÄܼÌÐø½øÐвÙ×÷¡£Èç¹ûÓû§µã»÷È·ÈÏ£¬Ä ......
IE¿ÉÒÔµ÷Óãº
<script type="text/javascript">
// ˵Ã÷£º»ñÈ¡Ò³ÃæÉÏÑ¡ÖеÄÎÄ×Ö
// ÕûÀí£ºhttp://www.CodeBit.cn
function getSelectedText() {
if (window.getSelection) {
// This technique is the most likel ......