这是所有用于删除外线并将您的 CSS 放在所需类名下的代码。 (IE 中的类名。)
标签示例
a{
_noFocusLine:expression(this.hideFocus=true);
outline-style:none;
outline:0;
}
HTML 页面中所有标签的示例!
*{
_noFocusLine:expression(this.hideFocus=true);
outline-style:none;
outline:0;
}
html 页面中带有 myClassName 类的标签示例!
.myClassName{
_noFocusLine:expression(this.hideFocus=true);
outline-style:none;
outline:0;
}
html 页面中带有 id myidName 的标签示例!
#myidName{
_noFocusLine:expression(this.hideFocus=true);
outline-style:none;
outline:0;
}
希望这有助于在主要浏览器中工作,如果不是它们太旧,那么还有多少人仍在使用这种旧浏览器的机会!
注意:outline:none 0; 也可以在较新的浏览器中使用,但不是全部。但是outline:0; 是通用的,在那些浏览器中不理解'none'并且你得到默认值,但是在所有使用这个大纲的浏览器中理解为0:。
IE7 需要这个_noFocusLine:expression(this.hideFocus=true);
其余部分使用 Javascript!
window.document.getElementById("myidName").blur();
window.document.getElementById("myidName").hideFocus=true;
window.document.getElementById("myidName").style.outline=0;
或
Obj=window.document.getElementById("myidName");
Obj.blur();
Obj.hideFocus=true;
Obj.style.outline=0;
或者检查元素是否存在!
if (window.document.getElementById("myidName")){
Obj=window.document.getElementById("myidName");
Obj.blur();
Obj.hideFocus=true;
Obj.style.outline=0;
}
Javascript 可以解决 IE6 和 IE7 的问题,而其他 CSS 则不行!