替换Select标签的javascript类
// 下拉列表类
// PubEdition: Version 1.0.0.0
// ModifyDate: 2009-12-09 9:30:00
// FinishDate: 2009-12-09 9:30:00
// AuthorName: binbin( Mail:pl45@163.com / Tel:13893302154 )
var droplistswap=function(){};
droplistswap.prototype.originalElement=new Array();
// droplistswap.prototype.hidedroplist=function(evt){
// var my = this;
// var _event = window.event?window.event:evt;
// var obj = _event.toElement?_event.toElement:_event.relatedTarget;
// while( obj!=null && obj.id!="droplistElement"){
// obj = obj.parentNode;
// }
// if(obj==null)document.getElementById("droplistElement").style.display="none";
// }
droplistswap.prototype.initialize=function(DropID,index){
var my = this;
my.originalElement.push(document.getElementById(DropID));
var selectElement=document.createElement('div');
selectElement.innerHTML="<label>"+document.getElementById(DropID).options[document.getElementById(DropID).selectedIndex].text+"</label>";
//selectElement.style.position="relative";
selectElement.id="selectElement"+index;
selectElement.className="droplistswap";
//selectElement.style.width="80px";
selectElement.style.top=document.getElementById(DropID).style.top;
selectElement.style.left= document.getElementById(DropID).style.left;
document.getElementById(DropID).parentNode.appendChild(selectElement);
document.getElementById(DropID).style.display="none";
//function的参数名称不能和类成员的参数名称相同
// my.addEventListener(document,"click",function(event){my.hidedroplist.call(my,event)});
my.addEventListener(selectElement,"click",function(event,p_ID,p_Index){my.handledroplist.call(my,event,DropID,index)});
}
droplistswap.prototype.handledroplist=function(evt,DropID,OriIndex)
{
var my = this;
//alert(OriIndex);
var _event = window.event?window.event:evt;
// if( _event == null ||typeof(_event) == 'undefined'){
// var _fun = my
相关文档:
avaScript通过内置的setTimeout函数来完成页面内的定时检查,也是很久以前写的东西了。
之所以想起它来,是因为在和项目组其他成员说该事情的时候,别人竟然嘲笑我说是上个世纪的代码,现在都用WEB2.0了。
<script language="JavaScript" type="text/JavaScript">
//增加系统扫描时间
var v_ ......
转化为Boolean类型
所有JavaScript中的值都能隐式的转化为Boolean类型,比如:
0 == false; // true
1 == true; // true
'' == false // true
null == false // true
但是这些值都不是Boolean类型。
因此当我们使用三个等 ......
"^\d+$" //非负整数(正整数 + 0)
"^[0-9]*[1-9][0-9]*$" //正整数
"^((-\d+)|(0+))$" //非正整数(负整数 + 0)
"^-[0-9]*[1-9][0-9]*$" //负整数
"^-?\d+$" //整数
"^\d+(\.\d+)?$" //非负浮点数(正浮点数 + 0)
"^(([0 ......
本文转自:http://bbs.51js.com/viewthread.php?tid=85083&extra=page%3D1
在自定义的函数中,如果要向函中提交一些参数,习惯性地大家会在函数中定义
例:<script>
function test(a,b){
alert(a);
alert(b);
}
test("第一次" ......
设为首页和添加收藏的Javascript代码,兼容性还可以,各种主流浏览器都测试通过了。
function addfavorite(){//加入收藏
if (document.all){
window.external.addFavorite("http://"+document.location.host+"/",document.title);
}else if (window.sidebar){
window.sidebar.addPanel(document.tit ......