Javascript²Ù×÷ÏÂÀ¿òµÄ³£Ó÷½·¨
ÔÎÄ£ºÁõÎä
| Javascript²Ù×÷ÏÂÀ¿òµÄ³£Ó÷½·¨
ÏîÄ¿ÖÐÅöµ½ÐèÒªÓÃjavascript²Ù×÷ÏÂÀ¿òµÄÇé¿ö£¬Ë³±ã×öÒ»ÏÂ×ܽᣬÁгöһЩ³£Ó÷½·¨£¬ÒÔÏ·½·¨¾ùÔÚFIRFOX3.5¼°IE8ÉϲâÊÔ¹ý£¬ÈçÓÐÆäËûä¯ÀÀÆ÷ÎÞ·¨Õý³£ÔËÐеÄÇëÓë±ÊÕßÁªÏµ¡£
//Ìí¼ÓÒ»¸öÏÂÀ¿ò
function AddDropDownList(id,fatherCtl)
{
if(!document.getElementById(id))
{
var ddl = document.createElement('select');
ddl.setAttribute("id",id);
if(fatherCtl&&document.getElementById(fatherCtl))
document.getElementById(fatherCtl).appendChild(ddl);
else
document.body.appendChild(ddl);
}
}
//ɾ³ýÖ¸¶¨µÄÏÂÀ¿ò
function RemoveDropDownList(id)
{
var ctl = document.getElementById(id);
if(ctl)
ctl.parentNode.removeChild(ctl);
}
//¸øÏÂÀ¿òÌí¼ÓÑ¡Ïî
function AddDDDLOption(id,text,value)
{
var ctl = document.getElementById(id);
if(ctl)
{
ctl.options[ctl.options.length] = new Option(text,value);
}
}
//ɾ³ýËùÓÐÑ¡Ïî
function RemoveAllDDLOptions(id)
{
var ctl = document.getElementById(id);
if(ctl)
{
ctl.options.length=0;
}
}
//ɾ³ýÖ¸¶¨Ë÷ÒýµÄÑ¡Ïî
function RemoveDDLOption(id,index)
{
var ctl=document.getElementById(id);
if(ctl && ctl.options[index])
{
ctl.options[index]=null;
}
}
//»ñÈ¡ÏÂÀ¿òÑ¡ÔñµÄÖµ
function GetDDLSelectedValue(id)
{
var ctl = document.getElementById(id);
if(ctl)
{
return ctl.options[ctl.selectedIndex].value;
}
}
//»ñÈ¡ÏÂÀ¿òÑ¡ÔñµÄÎı¾
function GetDDLSelectedText(id)
{
var ctl = document.getElementById(id);
if(ctl)
{
return ctl.options[ctl.selectedIndex].text;
}
}
Ïà¹ØÎĵµ£º
ʼþÔ´¶ÔÏó
event.srcElement.tagName
event.srcElement.type
²¶»ñÊÍ·Å
event.srcElement.setCapture();
event.srcElement.releaseCapture();
ʼþ°´¼ü
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
ʼþ·µ»ØÖµ
event.returnValue
Êó±êλÖÃ
event.x ......
¾¡¹Ü JavaScript ÀúÊ·ÉÏʹÓÃÈß³¤¶øÁîÈËÉúÑáµÄ´úÂë¿éÀ´±êµÄÌض¨ä¯ÀÀÆ÷µÄʱÆÚÒѾ½áÊøÁË£¬µ«ÊÇż¶ûʹÓÃһЩ¼òµ¥µÄ´úÂë¿éºÍ¶ÔÏó¼ì²âÀ´È·±£Ò»Ð©´úÂëÔÚÓû§»úÆ÷ÉÏÕý³£¹¤×÷ÒÀÈ»ÊDZØÒªµÄ¡£
ÕâƪÎÄÕÂÖУ¬ÎÒ»áÂÔÊöһϠInternet Explorer ºÍ Firefox ÔÚ JavaScript Óï·¨Éϲ»Í¬µÄ 7 ¸ö·½Ãæ¡£
1. CSS “float” ÊôÐÔ
»ñÈ¡ ......
ÔÚjsÀïÓõ½Êý×é,±ÈÈç ¶à¸öÃû×ÖÏàͬµÄinput, ÈôÊǶ¯Ì¬Éú³ÉµÄ, Ìύʱ¾ÍÐèÒªÅжÏÆäÊÇ·ñÊÇÊý×é.
if(document.mylist.length != "undefined" ) {} Õâ¸öÓ÷¨ÓÐÎó.
ÕýÈ·µÄÊÇ if( typeof(document.mylist.length) != "undefined" ) {}
»ò if( !isNaN(document.mylist.length) ) {}
typeofµÄÔËËãÊý䶨Òå,·µ»ØµÄ¾ÍÊÇ "un ......
½üÀ´¿´ÁËDeanµÄ“Convert any colour value to hex in MSIE”£¬ÖÕÓÚ½â¾öÁ˸ù¾Ý¹Ø¼ü×Ö»ñÈ¡ÑÕÉ«rgbÖµµÄÎÊÌâ¡£
˳±ã°Ñ³ÌÐòÒ²ÖØÐÂÕûÀíÒ»·¬£¬²¢Ê¹ÓÃÁË×î½üÕûÀíµÄ¹¤¾ß¿â¡£
Ч¹ûÔ¤ÀÀµ½ÕâÀï
ÏÂÔØÍêÕûʵÀý
³ÌÐò˵Ã÷
¡¾ColorGradsÑÕÉ«Ìݶȡ¿
³ÌÐòColorGradsµÄ×÷ÓÃÊǸù¾ÝÑÕÉ«¼¯ºÏºÍ½¥±ä¼¶ÊýÉú³ÉÑÕÉ«Ìݶȼ¯ºÏ¡£
½¥±ä¼ ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="re ......