javascript cookies²Ù×÷
<script>
//дcookiesº¯Êý ×÷ÕߣºµÔÕñ¿
function SetCookie(name,value)//Á½¸ö²ÎÊý£¬Ò»¸öÊÇcookieµÄÃû×Ó£¬Ò»¸öÊÇÖµ
{
var Days = 30; //´Ë cookie ½«±»±£´æ 30 Ìì
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//È¡cookiesº¯Êý
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name)//ɾ³ýcookie
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
SetCookie ("xiaoqi", " ......
JavaScriptÑéÖ¤ÕýÔò±í´ïʽ´óÈ«
Æ¥ÅäÖÐÎÄ×Ö·ûµÄÕýÔò±í´ïʽ£º [\u4E00-\uFA29]
ÆÀ×¢£ºÆ¥ÅäÖÐÎÄ»¹ÕæÊǸöÍ·ÌÛµÄÊ£¬ÓÐÁËÕâ¸ö±í´ïʽ¾ÍºÃ°ìÁË
Æ¥ÅäË«×Ö½Ú×Ö·û(°üÀ¨ºº×ÖÔÚÄÚ)£º[^x00-xff]
ÆÀ×¢£º¿ÉÒÔÓÃÀ´¼ÆËã×Ö·û´®µÄ³¤¶È£¨Ò»¸öË«×Ö½Ú×Ö·û³¤¶È¼Æ2£¬ASCII×Ö·û¼Æ1£©
Æ¥Åä¿Õ°×ÐеÄÕýÔò±í´ïʽ£ºns*r
ÆÀ×¢£º¿ÉÒÔÓÃÀ´É¾³ý¿Õ°×ÐÐ
Æ¥ÅäHTML±ê¼ÇµÄÕýÔò±í´ïʽ£º< (S*?)[^>]*>.*?|< .*? />
ÆÀ×¢£ºÍøÉÏÁ÷´«µÄ°æ±¾Ì«Ôã¸â£¬ÉÏÃæÕâ¸öÒ²½ö½öÄÜÆ¥Å䲿·Ö£¬¶ÔÓÚ¸´ÔÓµÄǶÌ×±ê¼ÇÒÀ¾ÉÎÞÄÜΪÁ¦
Æ¥ÅäÊ×β¿Õ°××Ö·ûµÄÕýÔò±í´ïʽ£º^s*|s*$
ÆÀ×¢£º¿ÉÒÔÓÃÀ´É¾³ýÐÐÊ×ÐÐβµÄ¿Õ°××Ö·û(°üÀ¨¿Õ¸ñ¡¢ÖƱí·û¡¢»»Ò³·ûµÈµÈ)£¬·Ç³£ÓÐÓõıí´ïʽ
Æ¥ÅäEmailµØÖ·µÄÕýÔò±í´ïʽ£ºw+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*
ÆÀ×¢£º±íµ¥Ñé֤ʱºÜʵÓÃ
Æ¥ÅäÍøÖ·URLµÄÕýÔò±í´ïʽ£º[a-zA-z]+://[^s]*
ÆÀ×¢£ºÍøÉÏÁ÷´«µÄ°æ±¾¹¦ÄܺÜÓÐÏÞ£¬ÉÏÃæÕâ¸ö»ù±¾¿ÉÒÔÂú×ãÐèÇó
Æ¥ÅäÕʺÅÊÇ·ñºÏ·¨(×Öĸ¿ªÍ·£¬ÔÊÐí5-16×Ö½Ú£¬ÔÊÐí×ÖĸÊý×ÖÏ»®Ïß)£º^[a-zA-Z][a-zA-Z0-9_]{4,15}$
ÆÀ×¢£º±íµ¥Ñé֤ʱºÜʵÓÃ
Æ¥Åä¹úÄڵ绰ºÅÂ룺d{3}-d{8}|d{4}-d{7}
ÆÀ×¢£ºÆ¥ÅäÐÎʽÈç 0511-4405222 »ò 021-87888822
Æ¥ÅäÌÚѶQQºÅ£º[1-9][0-9]{4,} ......
·½·¨Ò»:
¸öÈËÈÏΪ×îºÃµÄ·½·¨.²ÉÓõÄÊÇÕýÔò±í´ïʽ,ÕâÊÇ×îºËÐĵÄÔÀí.
Æä´Î.Õâ¸ö·½·¨Ê¹ÓÃÁËJavaScript µÄprototype ÊôÐÔ
ÆäʵÄ㲻ʹÓÃÕâ¸öÊôÐÔÒ»Ñù¿ÉÒÔÓú¯ÊýʵÏÖ.µ«ÕâÑù×öºóÓÃÆðÀ´±È½Ï·½±ã.
ÏÂÃæ¾ÍÀ´¿´¿´Õâ¸öÊôÐÔÊÇÔõôÀ´ÓõÄ.
·µ»Ø¶ÔÏóÀàÐÍÔÐ͵ÄÒýÓá£
objectName.prototype
objectName ²ÎÊýÊǶÔÏóµÄÃû³Æ¡£
˵Ã÷
Óà prototype ÊôÐÔÌṩ¶ÔÏóµÄÀàµÄÒ»×é»ù±¾¹¦ÄÜ¡£¶ÔÏóµÄÐÂʵÀý“¼Ì³Ð”¸³Óè¸Ã¶ÔÏóÔÐ͵IJÙ×÷¡£
ÀýÈ磬ҪΪ Array ¶ÔÏóÌí¼Ó·µ»ØÊý×éÖÐ×î´óÔªËØÖµµÄ·½·¨¡£ÒªÍê³ÉÕâÒ»µã£¬ÉùÃ÷¸Ãº¯Êý£¬½«Ëü¼ÓÈë Array.prototype£¬²¢Ê¹ÓÃËü¡£
Html´úÂë
function array_max( ){
var i, max = this[0];
for (i = 1; i < this.length; i++)
{
if (max < this[i])
max = this[i];
}
return max;
}
Array.prototype.max = array_max; &nbs ......
·ÃÎʿؼþµÄÖ÷Òª¶ÔÏóÊÇ:document¶ÔÏó¡£·Ö±ð¶ÔÓ¦µ±Ç°ÎĵµËùÓеģ¨×Ó¶ÔÏ󣩸öÈ˹۵㡣²¢ÇÒÒѾÌṩµÄ¼¸¸öÖ÷Òª·½·¨À´·ÃÎʶÔÏó¡£
1. document.getElementById
2. document.getElementsByName
3 document.getElementsByTagName
4 document.all
ÏÂÃæÎÒÖ÷Ҫ̸̸ÒÔÉϼ¸¸ö·½·¨µÄ¾ßÌåÓ÷¨£º
Ò»£®Ê×ÏÈÎÒÀ´Ì¸Ì¸document.getElementByIdµÄÓ÷¨¡£
Var obj=document.getElementById(“ID”) ¸ù¾ÝÖ¸¶¨µÄIDÊôÐÔÖµµÃµ½¶ÔÏó¡£·µ»ØidÊôÐÔÖµµÈÓÚIDµÄµÚÒ»¸ö¶ÔÏóµÄÒýÓ᣼ÙÈç¶ÔÓ¦µÄΪһ×é¶ÔÏó£¬Ôò·µ»Ø¸Ã×é¶ÔÏóÖеĵÚÒ»¸ö¡£
<input name=”a” type=”text” id=”b”/>
<input name=”b” type=”text” id=”a”/>
<input type=”button” name=”submint1” value=”text1” onclick=:”alert(document.getElementById(“b”)/>)”<input type=”button” name=”submint2” value=”text2” onclick=”alert(document.getElementById(“a”)/>)”ÎÒÔÚIEÖвâÊÔÁËÉÏÃæ´ú ......
´´½¨RegExp¶ÔÏóʵÀýµÄÁ½ÖÖ·½Ê½
1.ʹÓÃRegExp¶ÔÏóµÄÏÔʾ¹¹Ô캯Êý,Ó﷨Ϊ:new RegExp("pattern")[,"flags"];
2.ʹÓÃRegExp¶ÔÏóµÄÒþʾ¹¹Ô캯Êý,Ó﷨Ϊ:/pattern/flags;
3.flagsΪÒÔϱêÖ¾×Ö·ûµÄ×éºÏ
(1).g×÷È«¾Ö±êÖ¾,Èç¹ûûÓÐ,Æ¥ÅäµÚÒ»¸ö
(2). i ºöÂÔ´óСд
(3).m ¶àÐбêÖ¾
ÕýÔò±í´ïʽÓï·¨²Î¿¼
1.ÏÞ¶¨·û
(1).{n}:¹æ¶¨Ç°ÃæÑ¡ÏîÁ¬Ðø³öÏÖn´Î,o{2}:foooodÆ¥Åä2¸öo
(2).{n,}:¹æ¶¨Ç°ÃæÔªËØ»ò×éºÏÏîÖÁÉÙ³öÏÖn´Î,o{2,},zo²»ÐÐ,zoooo¿ÉÒÔ
(3).{n,m}:¹æ¶¨Ç°ÃæÔªËØÖÁÉÙÁ¬Ðø³öÏÖn´Î,×î¶àm´Î,o{1.3}
(4).+:±ØÐë³öÏÖÒ»´Î»òÁ¬Ðø¶à´Î.µÈЧÓÚ{1,},zo+:z²»ÐÐ,zooÐÐ
(5).*:³öÏÖ0´Î»òÁ¬Ðø¶à´Î,µÈЧ{0,},zo*,zÐÐ,zooÐÐ
(6).?:³öÏÖ0´Î»ò1´Î
2.Ñ¡ÔñÆ¥Åä·û
| : Æ¥ÅäÁ½¸öÑ¡ÏîÖÐÈÎÒâÒ»¸ö,ËüµÄÁ½¸öÑ¡ÏîÊÇ"|"×Ö·ûÁ½±ß¾¡¿ÉÄÜ×î´óµÄ±í´ïʽ.
chapter|section 1 :Æ¥ÅäµÄÊÇchapter »ò section 1
(chapter|section) 1 : Æ¥ÅäµÄÊÇchapter 1»ò section 1
3.·Ö×é×éºÏºÍ·´Ïò×÷Ó÷û
(1).(pattern):ºÏ³ÉÒ»¸ö×éºÏÏî,°´Ë³Ðò´æÔÚ»º³åÇøÖÐ.(ab);×ÖÃæÒâÒå()ÓÃ,"(",")"
(2).\num:µÚ¼¸¸ö ......
function getHeight(){
var yScroll;
if (window.innerHeight && window.scrollMaxY) {
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
yScroll = document.body.offsetHeight;
}
var windowHeight;
if (self.innerHeight) { // all except Explorer
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
// Explorer 6 Strict Mode
window ......