Multiple methods to remove link dashed boxes in CSS and JS
When we click the link, a dotted box is displayed around the link. How can we remove the dotted box? In fact, there are a lot of methods, you can use CSS, but using javaScript seems to be a good way.
1. the CSS method removes the link dashed box:
In IE, the html attribute hideFoucs is used. Add the hidefocus = "true" attribute to the HTML Tag. However, this attribute is private to IE and is not recognized by Firefox. Front-end framework example
. Code
- Added the hidefocus attribute.
CSS processing in IE:
. Code
- A {noOutline: expression (this. onFocus = this. blur ();}/* "onFocus" case sensitive */
Firefox's processing method is quite standard. You only need to set a: focus {outline: none} in the CSS style code. Next, let's take a look at the uniform processing methods in MSIE and FF:
. Code
- A {
- Outline: none;/* FF */
- NoOutline: expression (this. onFocus = this. blur ();/* IE */
- }
For performance optimization considerations, refer to the following code:
. Code
- A {outline: none ;}
- A: active {noOutline: expression (this. onFocus = this. blur ());}
- : Focus {outline: 0 ;}
2. Use js to solve the link dotted box: front-end framework example
. Code
- <Script language = "javascript">
- $ ("A"). bind ("focus", function (){
- If (this. blur ){
- This. blur ();
- }
- });
- </Script>