¶àä¯ÀÀÆ÷¼æÈÝÐÔÎÊÌâ¼°½â¾ö·½°¸Ö®Javascriptƪ
ʱ¼ä: 2009-9-02 - ·ÖÀà: Html+CSS, JavaScript - ÆÀÂÛ: 0 - ÔĶÁ: 70 ´Î
CSS¸úJavaScript¿ª·¢ÖУ¬×îÁî´ó¼ÒÍ·ÌÛµÄÎÊÌâ¾ÍÊÇä¯ÀÀÆ÷¼æÈÝÐÔÁË£¬ËäÈ»ºÜ¶àÎÄÕÂÓÐÕâ·½ÃæµÄÎÄÕ£¬µ«ÒÀÈ»Èúܶ࿪·¢ÈËÔ±ÔÎͷתÏò£¬¶øÇÒÒ²²»¹»È«Ãæ¡£ÕâƪÎÄÕ£¬½«È«ÃæÊÕ¼¯cssºÍjavascriptÔÚ¸÷ÖÖä¯ÀÀÆ÷ϵļæÈÝÐÔ±¨¸æ£¬Ò²ÆÚ´ý¸÷λ²»¶Ï²¹³ä¡£
ÓÉÓÚ·¢¾õÄÚÈÝÊÕ¼¯Ô½À´Ô½¶à£¬¾ö¶¨½«CSS¸úJavaScript·Ö¿ª¡£
Ò»¡¢document.formName.item(”itemName”) ÎÊÌâ
ÎÊÌâ˵Ã÷£ºIEÏ£¬¿ÉÒÔʹÓà document.formName.item(”itemName”) »ò document.formName.elements ["elementName"]£»Firefox Ï£¬Ö»ÄÜʹÓÃdocument.formName.elements["elementName"]¡£
½â¾ö·½·¨£ºÍ³Ò»Ê¹ÓÃdocument.formName.elements["elementName"]¡£
¶þ¡¢¼¯ºÏÀà¶ÔÏóÎÊÌâ
ÎÊÌâ˵Ã÷£ºIEÏ£¬¿ÉÒÔʹÓà () »ò [] »ñÈ¡¼¯ºÏÀà¶ÔÏó£»FirefoxÏ£¬Ö»ÄÜʹÓà [ ]»ñÈ¡¼¯ºÏÀà¶ÔÏó¡£
½â¾ö·½·¨£ºÍ³Ò»Ê¹Óà [] »ñÈ¡¼¯ºÏÀà¶ÔÏó¡£
Èý¡¢×Ô¶¨ÒåÊôÐÔÎÊÌâ
ÎÊÌâ˵Ã÷£ºIEÏ£¬¿ÉÒÔʹÓûñÈ¡³£¹æÊôÐԵķ½·¨À´»ñÈ¡×Ô¶¨ÒåÊôÐÔ£¬Ò²¿ÉÒÔʹÓà getAttribute() »ñÈ¡×Ô¶¨ÒåÊôÐÔ£»FirefoxÏ£¬Ö»ÄÜʹÓà getAttribute() »ñÈ¡×Ô¶¨ÒåÊôÐÔ¡£
½â¾ö·½·¨£ºÍ³Ò»Í¨¹ý getAttribute() »ñÈ¡×Ô¶¨ÒåÊôÐÔ¡£
ËÄ¡¢eval(”idName”)ÎÊÌâ
ÎÊÌâ˵Ã÷£ºIEÏ£¬¿ÉÒÔʹÓà eval(”idName”) »ò getElementById(”idName”) À´È¡µÃ id Ϊ idName µÄHTML¶ÔÏó£»FirefoxÏ£¬Ö»ÄÜʹÓà getElementById(”idName”) À´È¡µÃ id Ϊ idName µÄHTML¶ÔÏó¡£
½â¾ö·½·¨£ºÍ³Ò»Óà getElementById(”idName”) À´È¡µÃ id Ϊ idName µÄHTML¶ÔÏó¡£
Îå¡¢±äÁ¿ÃûÓëijHTML¶ÔÏóIDÏàͬµÄÎÊÌâ
ÎÊÌâ˵Ã÷£ºIEÏ£¬HTML¶ÔÏóµÄID¿ÉÒÔ×÷Ϊ document µÄÏÂÊô¶ÔÏó±äÁ¿ÃûÖ±½ÓʹÓã¬FirefoxÏÂÔò²»ÄÜ£»FirefoxÏ£¬¿ÉÒÔʹÓÃÓëHTML¶ÔÏóIDÏàͬµÄ±äÁ¿Ãû£¬IEÏÂÔò²»ÄÜ¡£
½â¾ö·½·¨£ºÊ¹Óà document.getElementById(”idName”) ´úÌæ document.idName¡£×îºÃ²»ÒªÈ¡HTML¶ÔÏóIDÏàͬµÄ±äÁ¿Ãû£¬ÒÔ¼õÉÙ´íÎó£»ÔÚÉùÃ÷±äÁ¿Ê±£¬Ò»ÂɼÓÉÏvar¹Ø¼ü×Ö£¬ÒÔ±ÜÃâÆçÒå¡£
Áù¡¢constÎÊÌâ
ÎÊÌâ˵Ã÷£ºFirefoxÏ£¬¿ÉÒÔʹÓÃconst¹Ø¼ü×Ö»òvar¹Ø¼ü×ÖÀ´¶¨Òå³£Á¿£»IEÏ£¬Ö»ÄÜʹÓÃvar¹Ø¼ü×ÖÀ´¶¨Òå³£Á¿¡£
½â¾ö·½·¨£ºÍ³Ò»Ê¹ÓÃvar¹Ø¼ü×ÖÀ´¶¨Òå³£Á¿¡£
Æß¡¢input.typeÊôÐÔÎÊÌâ
ÎÊÌâ˵Ã÷£ºIEÏ input.type ÊôÐÔΪֻ¶Á£»µ«ÊÇFirefoxÏ input.type ÊôÐÔΪ¶Áд¡£
½â¾ö°ì·¨
Ïà¹ØÎĵµ£º
½ñÌìÍ·¶ù¸´²é´úÂ룬½á¹û·¢ÏÖÓеÄÒ³Ã沢ûÓÐÏàÓ¦µÄDOMÔªËØ£¬µ¼Öµ÷ÓÃfuction³ö´í¡£²ÉÓÃJavaScriptÖÐarguments¶ÔÏó¿ÉÒÔºÜÇáËɵĽâ¾öÕâ¸öÎÊÌ⣬¶ø²»ÐèÒªÔÙÈ¥ÅжÏÔªËØÖ®ÀàµÄ¡£so Good£¡
JavaScriptÖÐargumentsº¯Êý¶ÔÏóÊǸöÔÏó´ú±íÕýÔÚÖ´Ðеĺ¯ÊýºÍµ÷ÓÃËüµÄº¯ÊýµÄ²ÎÊý¡£Ê¹Ó÷½·¨£º
[function.]arguments[n ]
ÆäÖÐfunctionÊÇ ......
±Õ°ü£¨closure£©ÊÇJavascriptÓïÑÔµÄÒ»¸öÄѵ㣬ҲÊÇËüµÄÌØÉ«£¬ºÜ¶à¸ß¼¶Ó¦Óö¼ÒªÒÀ¿¿±Õ°üʵÏÖ¡£
ÏÂÃæ¾ÍÊÇÎÒµÄѧϰ±Ê¼Ç£¬¶ÔÓÚJavascript³õѧÕßÓ¦¸ÃÊǺÜÓÐÓõġ£
Ò»¡¢±äÁ¿µÄ×÷ÓÃÓò
ÒªÀí½â±Õ°ü£¬Ê×ÏȱØÐëÀí½âJavascriptÌØÊâµÄ±äÁ¿×÷ÓÃÓò¡£
±äÁ¿µÄ×÷ÓÃÓòÎ޷ǾÍÊÇÁ½ÖÖ£ºÈ«¾Ö±äÁ¿ºÍ¾Ö²¿±äÁ¿¡£
JavascriptÓïÑÔµÄÌØÊâÖ®´¦£¬¾ÍÔ ......
ÔÚÍøÉÏÕÒµ½ÔÚIEϲÙ×÷IFrameÄÚÈݵĴúÂë:
document.frames["MyIFrame"].document.getElementById("s").style.color="blue";
µ«ÊÇÕâÔÚFirefoxÏÂÎÞЧ¡£
ËùÒÔ£¬Ïëµ½ÔÚFirefoxÏÂÓÃFireBugÀ´µ÷ÊÔ¡£¾¹ýµ÷ÊÔ·¢ÏÖÔÚFirefoxÏ¿ÉÓÃÒÔÏ´úÂëÀ´ÊµÏÖ:
document.getElementById("MyIFr ......
javascript cookies²Ù×÷
<script>
//дcookiesº¯Êý ×÷ÕߣºµÔÕñ¿
function SetCookie(name,value)//Á½¸ö²ÎÊý£¬Ò»¸öÊÇcookieµÄÃû×Ó£¬Ò»¸öÊÇÖµ
{
var Days = 30; //´Ë cookie ½«±»±£´æ 30 Ìì
var exp = new Date(); //new Date("December 31, 9998");
&n ......
function getHeight(){
var yScroll;
if (window.innerHeight && window.scrollMaxY) {
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offs ......