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;
}
}
Ïà¹ØÎĵµ£º
¾¡¹Ü JavaScript ÀúÊ·ÉÏʹÓÃÈß³¤¶øÁîÈËÉúÑáµÄ´úÂë¿éÀ´±êµÄÌض¨ä¯ÀÀÆ÷µÄʱÆÚÒѾ½áÊøÁË£¬µ«ÊÇż¶ûʹÓÃһЩ¼òµ¥µÄ´úÂë¿éºÍ¶ÔÏó¼ì²âÀ´È·±£Ò»Ð©´úÂëÔÚÓû§»úÆ÷ÉÏÕý³£¹¤×÷ÒÀÈ»ÊDZØÒªµÄ¡£
ÕâƪÎÄÕÂÖУ¬ÎÒ»áÂÔÊöһϠInternet Explorer ºÍ Firefox ÔÚ JavaScript Óï·¨Éϲ»Í¬µÄ 7 ¸ö·½Ãæ¡£
1. CSS “float” ÊôÐÔ
»ñÈ¡ ......
ðÅÝÐÍʼþ ʼþ·¢ÉúÓÉÄÚ¶øÍâ
¿ÉÒÔ¶Ôʱ¼ä´«µÝº¯ÊýÒÔÓ¦¶Ô¶¯×÷µÄ´Ù·¢
oP.attachEvent("onclick",fnClick); ¶Ô¶ÔÏóÔö¼ÓÒ»¸ö¼àÌýº¯Êý£¬Í¬Ò»¸ö¶ÔÏó¿ÉÒÔ¼àÌýÏàͬʼþ¶ÔÓ¦²»Í¬µÄʼþ´¦Àíº¯Êý Ö´ÐÐ˳ÐòºóÓÅÏÈ oP.detachEvent("onclick",fnClick);ɾ³ý¼àÌý ÊʺÏÓÃÓ ......
JavaScript--ÕýÔò±í´ïʽ
ÕýÔò±í´ïʽ(regular expression)¶ÔÏó°üº¬Ò»¸öÕýÔò±í´ïʽģʽ(pattern)¡£Ëü¾ßÓÐÓÃÕýÔò±í´ïʽģʽȥƥÅä»ò´úÌæÒ»¸ö´®(string)ÖÐÌض¨×Ö·û(»ò×Ö·û¼¯ºÏ)µÄÊôÐÔ(properties)ºÍ·½·¨(methods)¡£
ÕýÔò±í´ïʽ¹¹Ô캯Êý£º new RegExp("pattern"[,"flags"]);
²ÎÊý˵Ã÷£º
pattern -- Ò»¸öÕýÔò±í´ïʽÎı¾
flag ......
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 ......
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 ......