javascript ×Ö·û´®´¦ÀíÈ«¹¥ÂÔ
ÎÄÕ·ÖÀࣺ
JavaScript
ÎÄÕ±êÌ⣺
javascript ×Ö·û´®´¦ÀíÈ«¹¥ÂÔ
¹Ø ¼ü ×Ö£º
0
ÎÄÕÂ×÷Õߣº
alonglee
ÎÄÕÂÀ´Ô´£º
http://lmgq.vip.sina.com/tech/jsadvancedlesson/c2p1.htm
·¢±íʱ¼ä£º
2004-9-21 14:43:00
Ò»¡¢ÉùÃ÷×Ö·û´®:
var normal_monkey = "I am a monkey!<br>";
document.writeln("Normal monkey " + normal_monkey);
var bold_monkey = normal_monkey.bold();
document.writeln("Bold monkey " + bold_monkey);
ÕâÀïµÄÉùÃ÷£º var bold_monkey = normal_monkey.bold();
ºÍÏÂÃæ¶ÔÉùÃ÷ÊǵÈͬµÄ£º
var bold_monkey = "<b>" + normal_monkey + "</b>";
µÚ1¸ö°æ±¾µÄÉùÃ÷¿´ÆðÀ´Òª¼òÃ÷µÃ¶à¡£ÕâÀïÓõ½ÁË×Ö·û´®¶ÔÏóÖÐ
µÄbold¶ÔÏó£¬ÆäËûµÄ×Ö·û´®¶ÔÏó»¹ÓÐindexOf, charAt,
substring, ÒÔ¼°split, ÕâЩ·½·¨¿ÉÒÔÉîÈë×Ö·û´®µÄ×é³É½á¹¹¡£
Ê×ÏÈÎÒÃÇÑо¿Ò»ÏÂindexOf¡£
2¡¢indexOf
indexOfÓÃÓÚ·¢ÏÖһϵÁеÄ×Ö·ûÔÚÒ»¸ö×Ö·û´®ÖеÈλÖò¢¸æËßÄã×Ó×Ö·û´®µÄÆðʼλÖá£Èç
¹ûÒ»¸ö×Ö·û´®Öв¿°üº¬¸Ã×Ó×Ö·û´®ÔòindexOf·µ»Øreturns "-1."
Àý×Ó£º
var the_word = "monkey";
//ÈÃÎÒÃÇ´Óµ¥´Ê "monkey"¿ªÊ¼¡£
var location_of_m = the_word.indexOf("m");
//location_of_m(×ÖĸmµÄλÖÃ)½«Îª0£¬ÒòΪ×ÖĸmλÓÚ¸Ã×Ö·û´®µÄÆðʼλÖá£
var location_of_o = the_word.indexOf("o");
//location_of_o(×ÖĸoµÄλÖÃ)½«Îª1¡£
var location_of_key = the_word.indexOf("key");
//location_of_key(keyµÄλÖÃ)½«Îª3ÒòΪ×Ó×Ö·û´®“key”ÒÔ×Öĸk¿ªÊ¼£¬¶øk
ÔÚµ¥´ÊmonkeyÖеÄλÖÃÊÇ3¡£
var location_of_y = the_word.indexOf("y");
//location_of_y)×ÖĸyµÄλÖÃ)ÊÇ5¡£
var cheeky = the_word.indexOf("q");
//cheekyÖµÊÇ-1£¬ÒòΪÔÚµ¥´Ê“monk
Ïà¹ØÎĵµ£º
scrollHeight: »ñÈ¡¶ÔÏóµÄ¹ö¶¯¸ß¶È¡£
scrollLeft:ÉèÖûò»ñȡλÓÚ¶ÔÏó×ó±ß½çºÍ´°¿ÚÖÐÄ¿Ç°¿É¼ûÄÚÈݵÄ×î×ó¶ËÖ®¼äµÄ¾àÀë
scrollTop:ÉèÖûò»ñȡλÓÚ¶ÔÏó×¶ËºÍ´°¿ÚÖпɼûÄÚÈݵÄ×¶ËÖ®¼äµÄ¾àÀë
scrollWidth:»ñÈ¡¶ÔÏóµÄ¹ö¶¯¿í¶È
offsetHeight:»ñÈ¡¶ÔÏóÏà¶ÔÓÚ°æÃæ»òÓɸ¸×ø±ê offsetParent ÊôÐÔÖ¸¶¨µÄ¸¸×ø±êµÄ¸ß¶È
offsetL ......
ÀûÓõ÷Óü̳еĹؼüÖ»ÓÐÒ»²½²Ù×÷£º
¾ÍÊÇÔÚ×ÓÀඨÒåʱ£¬Í¨¹ý¸¸ÀàµÄ call ·½·¨£¬½«×ÓÀàµÄ this Ö¸Õë´«È롣ʹ¸¸Àà·½·¨ÔÚ×ÓÀàÉÏÏÂÎÄÖÐÖ´ÐС£
ÕâÑù£¬¸¸ÀàÖеÄËùÓÐÔÚ¸¸ÀàÄÚ²¿Í¨¹ý this ·½Ê½¶¨ÒåµÄ¹«ÓÐʵÀý³ÉÔ±¶¼»á±»×ÓÀà¼Ì³Ð¡£
Óà instanceof ÔËËã·ûÅжÏʱ£¬×ÓÀàµÄʵÀý»¯¶ÔÏóÖ»ÊôÓÚ×ÓÀ࣬²»ÊôÓÚ¸¸Àà¡£
²é¿´×ÓÀàµÄʵÀý»¯¶ÔÏóµÄ ......
6¡¢»ùÓÚ¶ÔÏóµÄJavaScriptÓïÑÔ
JavaScriptÊÇ»ùÓÚ¶ÔÏóµÄµÄÓïÑÔ£¬²»ÏñÃæÏò¶ÔÏóÓгéÏ󡢼̳С¢ÖØÔصÈÓйØÃæÏò¶ÔÏóµÄ¹¦ÄÜ£¬µ«ÊÇËü»¹ÊǾßÓÐÃæÏò¶ÔÏóµÄ»ù±¾ÌØÕ÷£¬Ëü¿ÉÒÔ¸ù¾ÝÐèÒª´´½¨×Ô¼ºµÄ¶ÔÏ󣬴Ӷø½øÒ»²½À©´óJavaScriptµÄÓ¦Ó÷¶Î§£¬ÔöÇ¿±àд¹¦ÄÜÇ¿´óµÄWebÎĵµ¡£
¶ÔÏóµÄ»ù´¡ÖªÊ¶£º
¶ÔÏóÊÇÓÉÊôÐԺͷ½·¨Á½¸ö»ù±¾ÔªËØ×é³É¡£Ò»¸ö¶Ô ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js³ýÈ¥×Ö·û´®¿Õ¸ñ ......
°ÑphpÊý¾Ý»òÖµ´«µÝ¸øjs
£ººÜ¼òµ¥£¬Ö±½ÓÔÚjsÖÐʹÓÃphp´úÂ룬»ì±à¼´¿É¡£
°ÑjsÊý¾Ý´«µÝ¸øphp
£º¿ÉÒÔʹÓôò¿ªÐ´°¿ÚµÄ·½Ê½£¬Í¨¹ýurlµØÖ·°ÑÊý¾Ý´«µÝ¹ýÈ¥¡£Ò²¿ÉÒÔʹÓÃajax£¬Í¨¹ýget»òpost´«µÝ¸øphp£¬Ò²¿ÉÒÔ±£´æcookieÈÃphpÀ´¶Á¡£
ÔÚ´«µÝÊý¾Ý¹ý³ÌÖпÉÄÜÓöµ½ÖÐÎıàÂë
ÎÊÌ⣬¿ÉÒÔͳһ±àÂ뷽ʽΪjsµÄescape£¬unescape£¬Ò²¿ÉÒÔÍ³Ò ......