firefox不支持disabled属性的解决方案----基于jquery。
??? 项目中遇到一个头疼的问题,firefox下设置<a>的disabled="disabled"无效。怎么办呢,只能求助于强大的JS了。
????? 思路如下:
????? 要实现对<a>的无效必须考虑几个方面:1.阻止 默认它的默认行为----超链接;2.阻止它的鼠标事件,代码中以onclick为例,代码中同样用到了jquery,谁叫它这么好用呢。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Insert title here</title><mce:script type="text/javascript" src="js/jquery.js" mce_src="js/jquery.js"></mce:script></head><mce:script type="text/javascript"><!--$(function(){$("a[disabled]").addClass("disable");//添加新的class 注意这里不会覆盖标签原有的class});function clickEvent(oEvent){var oEvent = oEvent ? oEvent : window.event; oEvent.preventDefault();//阻止超链接var tar; if(navigator.appName=="Microsoft Internet Explorer"){tar = oEvent.srcElement;}else{tar=oEvent.target;}if(tar.getAttribute("disabled")){return false;//阻止点击事件}alert("谁说我没有用!?");};function clickEvent1(oEvent){alert("谁说我没有用!?");};// --></mce:script><mce:style><!--.disable{ color:gray;//弄成灰的模拟disabled}--></mce:style><style mce_bogus="1">.disable{ color:gray;//弄成灰的模拟disabled}</style><body><p><a href="http://baidu.com" mce_href="http://baidu.com" disabled="disabled" title="这是默认提示1." onclick="clickEvent1(event);">我应该是没用的</a></p><p><a href="http://baidu.com" mce_href="http://baidu.com" disabled="disabled" title="这是默认提示1." onclick="clickEvent(event);">我现在真的没用了</a></p></body></html><a href="#" style="color:#ACA899">#</a>
??