JavaScript×Ö·û´®º¯Êý´óÈ«
JS×Ô´øº¯Êý
concat
½«Á½¸ö»ò¶à¸ö×Ö·ûµÄÎı¾×éºÏÆðÀ´£¬·µ»ØÒ»¸öеÄ×Ö·û´®¡£
var a = "hello";
var b = ",world";
var c = a.concat(b);
alert(c);
//c = "hello,world"
indexOf
·µ»Ø×Ö·û´®ÖÐÒ»¸ö×Ó´®µÚÒ»´¦³öÏÖµÄË÷Òý£¨´Ó×óµ½ÓÒËÑË÷£©¡£Èç¹ûûÓÐÆ¥ÅäÏ·µ»Ø -1 ¡£
var index1 = a.indexOf("l");
//index1 = 2
var index2 = a.indexOf("l",3);
//index2 = 3
charAt
·µ»ØÖ¸¶¨Î»ÖõÄ×Ö·û¡£
var get_char = a.charAt(0);
//get_char = "h"
lastIndexOf
·µ»Ø×Ö·û´®ÖÐÒ»¸ö×Ó´®×îºóÒ»´¦³öÏÖµÄË÷Òý£¨´ÓÓÒµ½×óËÑË÷£©£¬Èç¹ûûÓÐÆ¥ÅäÏ·µ»Ø -1 ¡£
var index1 = lastIndexOf('l');
//index1 = 3
var index2 = lastIndexOf('l',2)
//index2 = 2
match
¼ì²éÒ»¸ö×Ö·û´®Æ¥ÅäÒ»¸öÕýÔò±í´ïʽÄÚÈÝ£¬Èç¹ûôÓÐÆ¥Åä·µ»Ø null¡£
var re = new RegExp(/^\w+$/);
var is_alpha1 = a.match(re);
//is_alpha1 = "hello"
var is_alpha2 = b.match(re);
//is_alpha2 = null
substring
·µ»Ø×Ö·û´®µÄÒ»¸ö×Ó´®£¬´«Èë²ÎÊýÊÇÆðʼλÖúͽáÊøλÖá£
var sub_string1 = a.substring(1);
//sub_string1 = "ello"
var sub_string2 = a.substring(1,4);
//sub_string2 = "ell"
substr
·µ»Ø×Ö·û´®µÄÒ»¸ö×Ó´®£¬´«Èë²ÎÊýÊÇÆðʼλÖúͳ¤¶È
var sub_string1 = a.substr(1);
//sub_string1 = "ello"
var sub_string2 = a.substr(1,4);
//sub_string2 = "ello"
replace
ÓÃÀ´²éÕÒÆ¥ÅäÒ»¸öÕýÔò±í´ïʽµÄ×Ö·û´®£¬È»ºóʹÓÃÐÂ×Ö·û´®´úÌæÆ¥ÅäµÄ×Ö·û´®¡£
var result1 = a.replace(re,"Hello");
//result1 = "Hello"
var result2 = b.replace(re,"Hello");
//result2 = ",world"
search
Ö´ÐÐÒ»¸öÕýÔò±í´ïʽƥÅä²éÕÒ¡£Èç¹û²éÕҳɹ¦£¬·µ»Ø×Ö·û´®ÖÐÆ¥ÅäµÄË÷ÒýÖµ¡£·ñÔò·µ»Ø -1 ¡£
var index1 = a.search(re);
//index1 = 0
var index2 = b.search(re);
//index2 = -1
slice
ÌáÈ¡×Ö·û´®µÄÒ»²¿·Ö£¬²¢·µ»ØÒ»¸öÐÂ×Ö·û´®£¨Óë substring Ïàͬ£©¡£
var sub_string1 = a.slice(1);
//sub_string1 = "ello"
var sub_string2 = a.slice(1,4);
//sub_string2 = "ell"
split
ͨ¹ý½«×Ö·û´®»®·Ö³É×Ó´®£¬½«Ò»¸ö×Ö·û´®×ö³ÉÒ»¸ö×Ö·û´®Êý×é¡£
var arr1 = a.split("");
//arr1 = [h,e,l,l,o]
length
·µ»Ø×Ö·û´®µÄ³¤¶È£¬Ëùν×Ö·û´®µÄ³¤¶ÈÊÇÖ¸Æä°üº¬µÄ×Ö·ûµÄ¸öÊý¡£
var len = a.length();
//len = 5
toLowerCase
½«Õû¸ö×Ö·û´®×ª³ÉСд×Öĸ¡£
var lower_stri
Ïà¹ØÎĵµ£º
<a href="#" onclick="ChildNode(this);">aaa</a>Òª¸ÄΪ
<a href="#" onclick="ChildNode(event);">aaa</a>
ÎÞ·¨È¡µÃthis¶ÔÏó£¬ÒªÓÃÒÔÏ·½·¨À´È¡µÃ¡£
function ChildNode(e)
{
var evt = e ? e : (window.event ? window.event : null); //´Ë·½·¨ÎªÁËÔÚfirefoxÖеļæÈÝ
var node = evt.srcEl ......
ÖصãÔÚÓÚfunction scroll()£¬function clipShow()¼°ÒÔÏÂforÑ»·¡£
ÎÞ·ì¹ö¶¯ÐÂÎŵÄJavascriptÔ´´úÂ룬·ÅÔÚÕâÀÓÐÐèÒªµÄʱºò¿ÉÄÜÓõÃÉÏ£º
//CSSÑùʽ
<style>
.new_newsT{
padding-top: 10px;
padding-bottom: 8px;
}
.new_newsT .list {
CLEAR: both; MARGIN: 0px 6px 0px 10px
}
......
ÍøÒ³ÖÆ×÷Javascript¾µäС¼¼ÇÉ×ܽá
http://www.webjx.com ¸üÐÂÈÕÆÚ£º2007-10-12 01:25 ³ö´¦£ºÍøÒ³½ÌѧÍø ×÷ÕߣºÕ¾³¤ÕûÀí
ÿһÏÊÇJSÖеÄС¼¼ÇÉ£¬µ«Ê®·ÖµÄʵÓã¡
1.document.write(”"); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document->html->(head,body)
4.Ò»¸öä¯ÀÀÆ ......
±íµ¥µÄ¿Í»§¶ËjavascriptÑéÖ¤Óи÷ÖÖ¸÷ÑùµÄд·¨£¬µÇ¼ΪformµÄonsubmitʼþ»òsubmit°´Å¤Ð´Ò»¸öº¯Êý¡£¶ÔÓÚС±íµ¥£¨Ö»ÓÐÒ»Á½¸ö±íµ¥ÓòµÄ±íµ¥£©¾Í²»±ØÔÙרÃÅÔÙÓÃjavascriptдһ¸öÑéÖ¤º¯ÊýÁË£¬Ö»ÐèÒªÔÚformµÄonsubmitʼþÀï¼ÓÉÏ£º
onsubmit=”return domainname.value==”?(alert(’ÇëÊäÈëËÑË÷ÄÚÈÝ’),false ......
AA.HTM
-------------------------------------
<!--
showModalDialogº¯ÊýµÄʹÓà (ת)
±¾·¶Àý¿ÉÒÔʵÏÖµ¯³öÒ»¸öģ̬´°¿Ú£¬²¢ÑÝʾÁËÁ½ÖÖ½ÓÊպʹ«µÝ²ÎÊýµÄ·½·¨£¬Í¬Ê±¿ÉÒÔ½ÓÊÜģ̬´°¿Ú·µ»ØµÄ¶à¸ö±äÁ¿
-->
<html> &nbs ......