动态网页在使用过程中,有时需要使用javascript来动态控制某个网页元素的一些事件,比如当用户做一些操作后需要禁止元素的onmouseover事件,而在做一些其他操作后又需要打开此事件时,就需要进行动态控制了,方法如下:
function disableAllPriceButton(v){
obj=document.getElementById("APB_1");
if(!v)
{
obj.onmouseover=function(){this.className='pai_bidactionhover';};
obj.onmouseout=function(){this.className='pai_bidaction';};
obj.detachEvent ("onclick",addPrice);
obj.attachEvent("onclick",addPrice);
obj.className="pai_bidaction";
}else{
obj.onmouseover=function(){};
obj.onmouseout=function(){};
obj.detachEvent ("onclick",addPrice);
obj.className="pai_bidactionoff";
}
}
function addPrice(){
alert(event.srcElement.id);
}
obj=document.getElementById("APB_1");
if(!v)
{
obj.onmouseover=function(){this.className='pai_bidactionhover';};
obj.onmouseout=function(){this.className='pai_bidaction';};
obj.detachEvent ("onclick",addPrice);
obj.attachEvent("onclick",addPrice);
obj.className="pai_bidaction";
}else{
obj.onmouseover=function(){};
obj.onmouseout=function(){};
obj.detachEvent ("onclick",addPrice);
obj.className="pai_bidactionoff";
}
}
function addPrice(){
alert(event.srcElement.id);
}