操作ClassName的工具函数(JavaScript权威指南)
/**
* CSSClass.js
*/
var CSSClass = {}; //Create our namespace object
//Return tru if element e is a member of the class c;false otherwise
CSSClass.is = fucntion(e, c)
{
if(typeof e == "string")
e = document.getElementById(e);
//Before doing a regexp search,optimize for couple of common cases.
var classes = e.className;
if(!classes){return false;}
if(classes == c){return true;}
// Otherwise, user a regular expression to search for c as a word by itself
// \b in a regular expression requires a match at a word boundary,
return e.className.search("\\b" + c + "\\b") != -1;
};
// Add class c to the className of element e if it is not already there.
CSSClass.add = function(e, c)
{
if(typeof e == "string")
{
e = document.getElementById(e);
if(CSSClass.is(e, c))//If already amember, do nothing
{
return;
}
//Whitespace a separator, if needed
if(e.classeName)
{
c= ""+c
}
e.className = += c; //Append the new class to the end
}
};
//Remove all occurrences(if any) of class c from the className of element e
CSSClass.remove = function(e, c)
{
if(typeof e == "string")
{
e = document.getElementById(e);
}
//Search the className for all ovvurrences of c and replace with "".
// \s* matches any number of whitespace characters.
// "g" makes the regular expression match any number of occurrences.
e.className = e.className.replace(new RegExp("\\b" + c + "\\b\\s*", "g"), "");
};
相关文档:
原文网址:http://www.ccvita.com/?s=onbeforepaste
javascript事件列表解说javascript事件列表解说
事件 浏览器支持 解说
一般事件 onclick IE3、N2 鼠标点击时触发此事件
ondblclick IE4、N4 鼠标双击时触发此事件
onmousedown IE4、N4 按下鼠标时触发此事件
onmouseup IE4、N4 鼠标按下后松开鼠标时触发此事 ......
大一点的框架都有这个东西。Prototype原来的继承机制非常弱,为了与mootools对抗也强化了这一方面。嘛,要用原型继承来模仿类继承,都基本存在一个克隆函数。把父类的原型属性复制到子类上去。理念的东西暂时这么多,动手实践一下最实际。我们设计一个数组类,拥有原生数组的能力与新扩展的能力。
var isNumber ......
using System;
using System.Data;
public partial class CheckBox:System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//生成DataTable并添加相应的列
DataTable dt = new DataTable();
dt.Columns.Add("ID");
dt.Columns.Add("Autho ......
在JavaScript中字符串是用引号“" "”、“' '”包起来的零个至多个字符。用哪个引号开始就用哪个结束,而且单双引号可嵌套使用,不过JavaScript 中引号的嵌套只能有一层。如果想再多嵌一些,需要用转义字符:
转义字符 由于一些字符在屏幕上不能显示,或者 JavaScript 语法上已经有了特殊用途, ......
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=" ......