南阳网站建设新闻,网站 跳出率 多少,net开发网页小程序,专业做汽配的网站对于anchor tags(a/a)#xff0c;IE支持一个非标准的disabled属性#xff0c;但支持也不完善#xff0c;比如#xff0c;如果这个anchor tage没有 href 值#xff0c;IE会把这个anchor设置为灰色#xff0c;当然不能点击#x…对于anchor tags(a/a)IE支持一个非标准的disabled属性但支持也不完善比如如果这个anchor tage没有 href 值IE会把这个anchor设置为灰色当然不能点击也没有下划线。但如果这个anchor tag有href值IE并不会真的disable这个anchor,而只是把字的颜色设为灰色并且可以点击也有下划线。Firefox则完全不支持这个非标准的属性。 为了给所有的浏览器都提供disable anchor tage的功能有这么一些方法 覆盖override)onclick事件并让这个事件什么动作也不作同时用CSS修改anchor的外观。更简单的方法是 如果想disable一个anchor就去掉它的href属性。所有的浏览器同时也会disable这个anchor,并且去掉所有的超链接外观和反应比如去掉下划线鼠标不会变为手型文字不会变为蓝色并且这种方法disable的anchor文字不会变为无法修改的灰色。为了实现这种效果我们需要在删除href属性之前备份一个备份可以存储在一个我自己增加的非标准href_bak属性中下面是javascript实现代码 function disableAnchor(obj, disable){ if(disable){ var href obj.getAttribute(href); if(href href ! href ! null){ obj.setAttribute(href_bak, href); } obj.removeAttribute(href); obj.style.colorgray; } else{ obj.setAttribute(href, obj.attributes[href_bak].nodeValue); obj.style.colorblue; } } 原文参见IE and Firefox compatible javascript to enable or disable an anchor tag