ÓÃJavascriptÖÆ×÷Õ¾ÄÚËÑË÷Æ÷
ÓÃJavaScript×öµÄÕ¾ÄÚËÑË÷²»½ö±à³ÌʵÏÖ¡¢Î¬»¤ÆðÀ´ºÜ¼òµ¥£¬¶øÇÒËüÄÜÔÚ¿Í»§¶Ëä¯ÀÀÆ÷Ö±½ÓÖ´ÐУ¬ÎÞÐë·þÎñÆ÷µÄÖ§³Ö£¬Ò²¿ÉÒÔÊ¡È¥ÉêÇëÓнű¾Ö´ÐÐȨÏÞ¿Õ¼äµÄÂé·³¡£ËùÒÔ£¬Ö»ÒªÄãÔ¸Ò⶯ÊÖ£¬ÓиöÈËÖ÷Ò³¾ÍÄÜÓÐ×Ô¼ºµÄÕ¾ÄÚËÑË÷¡£ÏÂÃæÈÃÎÒÃǹ²Í¬À´×öÒ»¸ö»ùÓÚJavaScriptµÄÕ¾ÄÚËÑË÷µÄ½Å±¾£¬¿É²»ÒªÐ¡¿´Ëü£¬×öÍêÁËÄã¾ÍÖªµÀËüµÄºÃ´¦ÁË¡£
Ê×ÏÈ£¬ÄãÒª±àдһ¸öËÑË÷±íµ¥£¬½«Óû§ÒªËÑË÷µÄÊý¾ÝÌá½»¸øJavaScriptº¯Êý¡£×î¼òµ¥µÄ´úÂëÈçÏ£¬ÒòΪÊÇ×î¼òµ¥µÄHTML´úÂ룬ËùÒԾͲ»×÷½âÊÍÁË£º
<form name="search" onsubmit="goSearch(this)">
<input type="text" size="22" name="searchStr" value="¶à¸ö¹Ø¼ü×ÖÇëÒÔ¿Õ¸ñ¸ô¿ª" onmouseover="this.focus()" onfocus="this.select()">
<select name="select" size="1">
<option selected>»òÕß(or)</option>
<option>²¢ÇÒ(and)</option>
<option selected>²»°üº¬(no)</option>
</select>
<input type="submit" name="submit" value="ËÑË÷">
</form>
Æä´Î£¬Òª¶ÔÄãµÄÕ¾µãµÄÊý¾Ý³õʼ»¯¡£ÕâÊÇËÑË÷ʱҪÓõ½µÄÊý¾Ý¿â£¬Õ¾µã¸üÐÂÖ»Òª¸ü¸ÄÕâЩÊý¾Ý¾ÍÐÐÁË¡£¶ÔÓÚÕâ¸öÊý¾Ý¿â£¬½¨Òéµ¥¶À´æΪһ¸öÎļþ£¬ÔÚÕâÀïÎÒÃÇÏÈ´æΪÏàͬ·¾¶ÏµÄ"db.js"
/* Õ¾µãÊý¾Ý¿âdb.js¿ªÊ¼ */
function initArray(){ /* ¶¨ÒåÊý×é³õʼ»¯º¯Êý */
this.length=initArray.arguments.length;
for(var i=0;i<this.length;i++) this[i]=initArray.arguments[i];
}
/* ¶¨Òå´ýËÑË÷µÄÒ³ÃæµÄ±êÌ⣬ûÓÐÏȺó˳Ðò£¬Ó¦½«´ýËÑË÷µÄÒ³Ã涼Áгö */
var titles=new initArray('Ò³Ãæ±êÌâ1','Ò³Ãæ±êÌâ2',……);
/* ÕâЩҳÃæµÄÏêϸ˵Ã÷£¬Î»ÖÃÓ¦¸ÃÓëËüÃǵıêÌâÒ»Ö */
var descriptions=new initArray('Ïêϸ˵Ã÷1','Ïêϸ˵Ã÷2',……);
/* ´ýËÑË÷Ò³ÃæµÄµØÖ·£¬½¨ÒéʹÓÃÔÚÄãÕ¾µãÉϵÄÏà¶ÔµØÖ·£¬Î»ÖÃÒ²Ó¦Óë±êÌ⡢˵Ã÷ÏàÒ»Ö */
var URLs=new initArray('url1','url2',……);
/* Õ¾µãÊý¾Ý¿âdb.js½áÊø */
¼ÆËã»úµç×ÓÊé¼®
µÚÈý²½£¬³õʼ»¯Óû§ÊäÈëµÄËÑË÷×Ö·û´®£¬²¢½«Ëü´«µÝ¸øËÑË÷º¯Êý£¬Áгö½á¹û¡£
function goSearch(){
var searchStr=document.search.searchStr.value; /* È¡µÃ±íµ¥ÖеÄÓû§ÊäÈëµÄËÑË÷×Ö·û */
var string1=searchStr.toLowerCase(); /* ת»»ÎªÐ¡Ð´£¬±ÜÃâ´óСдÃô¸Ð */
var length1=st
Ïà¹ØÎĵµ£º
scrollHeight: »ñÈ¡¶ÔÏóµÄ¹ö¶¯¸ß¶È¡£
scrollLeft:ÉèÖûò»ñȡλÓÚ¶ÔÏó×ó±ß½çºÍ´°¿ÚÖÐÄ¿Ç°¿É¼ûÄÚÈݵÄ×î×ó¶ËÖ®¼äµÄ¾àÀë
scrollTop:ÉèÖûò»ñȡλÓÚ¶ÔÏó×¶ËºÍ´°¿ÚÖпɼûÄÚÈݵÄ×¶ËÖ®¼äµÄ¾àÀë
scrollWidth:»ñÈ¡¶ÔÏóµÄ¹ö¶¯¿í¶È
offsetHeight:»ñÈ¡¶ÔÏóÏà¶ÔÓÚ°æÃæ»òÓɸ¸×ø±ê offsetParent ÊôÐÔÖ¸¶¨µÄ¸¸×ø±êµÄ¸ß¶È
offsetL ......
Ò³Ã棺
<script type="text/javascript" src="js/test.js"></script>
¡£¡£¡£¡£
<body onload="new myTest();" >
ÒÔ¶ÔÏó·½Ê½µ÷ÓÃÐèҪʹÓà new ²Ù×÷·û£¬test.jsµÄÄÚÈÝ:
{ & ......
¡¡¡¡´ËÎÄΪ¶Á¡¶JavaScript And DHTML Cookbook¡·ºó×ܽá³öÀ´µÄ±Ê¼Ç¡£ÓÉÓÚµ±Ê±Êdzõѧ£¬ËùÒԱʼÇÖÐÄÑÃâÓдíÎ󣬻¶ÓÖ¸Õý¡£Ð»Ð»£¡
·×Ö·û´®(String)
1.ÉùÃ÷
var myString = new String("Every good boy does fine.");
var myString = "Every good boy does fine.";
&n ......
//ÅжÏÊäÈëÄÚÈÝÊÇ·ñΪ¿Õ
function IsNull(){
var str = document.getElementById('str').value.trim();
if(str.length==0){
alert('¶Ô²»Æð£¬Îı¾¿ò²»ÄÜΪ¿Õ»òÕßΪ¿Õ¸ñ!');//Ç뽫“Îı¾¿ò”¸Ä³ÉÄãÐèÒªÑéÖ¤µÄÊôÐÔÃû³Æ!
}
}
//ÅжÏÈÕÆÚÀàÐÍÊÇ·ñÎ ......