¡¶JavaScript And DHTML Cookbook¡·Ñ§Ï°±Ê¼Ç
¡¡¡¡´ËÎÄΪ¶Á¡¶JavaScript And DHTML Cookbook¡·ºó×ܽá³öÀ´µÄ±Ê¼Ç¡£ÓÉÓÚµ±Ê±Êdzõѧ£¬ËùÒԱʼÇÖÐÄÑÃâÓдíÎ󣬻¶ÓÖ¸Õý¡£Ð»Ð»£¡
·×Ö·û´®(String)
1.ÉùÃ÷
var myString = new String("Every good boy does fine.");
var myString = "Every good boy does fine.";
2.×Ö·û´®Á¬½Ó
var myString = "Every " + "good boy " + "does fine.";
var myString = "Every "; myString += "good boy does fine.";
3.½ØÈ¡×Ö·û´®
//½ØÈ¡µÚ 6 λ¿ªÊ¼µÄ×Ö·û
var myString = "Every good boy does fine.";
var section = myString.substring(6); //½á¹û: "good boy does fine."
//½ØÈ¡µÚ 0 λ¿ªÊ¼ÖÁµÚ 10 λΪֹµÄ×Ö·û
var myString = "Every good boy does fine.";
var section = myString.substring(0,10); //½á¹û: "Every good"
//½ØÈ¡´ÓµÚ 11 λµ½µ¹ÊýµÚ 6 λΪֹµÄ×Ö·û
var myString = "Every good boy does fine.";
var section = myString.slice(11,-6); //½á¹û: "boy does"
//´ÓµÚ 6 λ¿ªÊ¼½ØÈ¡³¤¶ÈΪ 4 µÄ×Ö·û
var myString = "Every good boy does fine.";
var section = myString.substr(6,4); //½á¹û: "good"
4.ת»»´óСд
var myString = "Hello";
var lcString = myString.toLowerCase(); //½á¹û: "hello"
var ucString = myString.toUpperCase(); //½á¹û: "HELLO"
5.×Ö·û´®±È½Ï
var aString = "Hello!";
var bString = new String("Hello!");
if( aString == "Hello!" ){ } //½á¹û: true
if( aString == bString ){ } //½á¹û: true
if( aString === bString ){ } //½á¹û: fa
Ïà¹ØÎĵµ£º
scrollHeight: »ñÈ¡¶ÔÏóµÄ¹ö¶¯¸ß¶È¡£
scrollLeft:ÉèÖûò»ñȡλÓÚ¶ÔÏó×ó±ß½çºÍ´°¿ÚÖÐÄ¿Ç°¿É¼ûÄÚÈݵÄ×î×ó¶ËÖ®¼äµÄ¾àÀë
scrollTop:ÉèÖûò»ñȡλÓÚ¶ÔÏó×¶ËºÍ´°¿ÚÖпɼûÄÚÈݵÄ×¶ËÖ®¼äµÄ¾àÀë
scrollWidth:»ñÈ¡¶ÔÏóµÄ¹ö¶¯¿í¶È
offsetHeight:»ñÈ¡¶ÔÏóÏà¶ÔÓÚ°æÃæ»òÓɸ¸×ø±ê offsetParent ÊôÐÔÖ¸¶¨µÄ¸¸×ø±êµÄ¸ß¶È
offsetL ......
ðÅÝÐÍʼþ ʼþ·¢ÉúÓÉÄÚ¶øÍâ
¿ÉÒÔ¶Ôʱ¼ä´«µÝº¯ÊýÒÔÓ¦¶Ô¶¯×÷µÄ´Ù·¢
oP.attachEvent("onclick",fnClick); ¶Ô¶ÔÏóÔö¼ÓÒ»¸ö¼àÌýº¯Êý£¬Í¬Ò»¸ö¶ÔÏó¿ÉÒÔ¼àÌýÏàͬʼþ¶ÔÓ¦²»Í¬µÄʼþ´¦Àíº¯Êý Ö´ÐÐ˳ÐòºóÓÅÏÈ oP.detachEvent("onclick",fnClick);ɾ³ý¼àÌý ÊʺÏÓÃÓ ......
JavaScriptʹÓ÷½·¨ºÍ¼¼ÇÉ´óÈ«
ÓÐЩʱºòÄ㾫ͨһÃÅÓïÑÔ£¬µ«ÊǻᷢÏÖÄãÆäʵÕûÌìÔÚºÍÆäËüÓïÑÔ´ò½»µÀ£¬Ò²ÐíÄãÒÔΪÕâЩ΢²»×ãµÀ£¬²»ÖÁÓÚÓ°ÏìÄãµÄ¿ª·¢½ø¶È£¬µ«Ç¡Ç¡ÊÇÕâЩÄã²»ÖØÊӵĶ«Î÷»áÀË·ÑÄãºÜ¶àʱ¼ä£¬ÎÒÒ»Ö±ÒÔΪÎÒÔçÔÚ¼¸ÄêÇ°¾ÍÒѾ¾«Í¨JavaScriptÁË£¬Ö±µ½Ä¿Ç°£¬ÎÒ²ÅÔ½ ......
Code:
<!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>
<title>ÎÞ±êÌâÒ³</title>
<mce:script language="javascript" type="te ......
ÔÚJavaScriptÖÐûÓÐרÃŵĻúÖÆÀ´ÊµÏÖÀàµÄ¼Ì³Ð£¬µ«ÊÇ¿ÉÒÔͨ¹ý¿½±´Ò»¸öÀàµÄprototypeµ½ÁíÍâÒ»¸öÀàÀ´ÊµÏּ̳У¬Ò»ÖÖ¼òµ¥µÄʵÏÖÈçÏ£º
function class1(){
}
function class2(){
}
class2.prototype=class1.prototype;
class2.prototype.moreProperty="xxx";
class2.prototype.moreMethod1=function(){
}
var obj = ne ......