Multiple methods to remove link dashed boxes in CSS and JS

Source: Internet
Author: User

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
  1. Added the hidefocus attribute.

    CSS processing in IE:

    . Code
    1. 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
      1. A {
      2. Outline: none;/* FF */
      3. NoOutline: expression (this. onFocus = this. blur ();/* IE */
      4. }

        For performance optimization considerations, refer to the following code:

        . Code
        1. A {outline: none ;}
        2. A: active {noOutline: expression (this. onFocus = this. blur ());}
        3. : Focus {outline: 0 ;}

          2. Use js to solve the link dotted box: front-end framework example

          . Code
          1. <Script language = "javascript">
          2. $ ("A"). bind ("focus", function (){
          3. If (this. blur ){
          4. This. blur ();
          5. }
          6. });
          7. </Script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.