Home > Web Front-end > JS Tutorial > Use javascript to convert external link styles

Use javascript to convert external link styles

黄舟
Release: 2016-12-19 17:25:05
Original
2047 people have browsed it

Use CSS attribute selectors to selectively control link styles, such as adding a small icon to all external links to identify them as external links.

 But there are disadvantages to using CSS:

 1. It only supports browsers such as Firefox that have good support for web standards.

 2. It can only judge links, not anchor points or javascript. If you encounter it, there is nothing you can do.

This can be done with js. First write a style:

The following is a reference fragment:
a.other:link,a.other:visited,a.other:active
{
background:url("external.gif ") no-repeat top right;
  padding-right:15px;
}

               Write another js, but the js should take into account the diversity of links, such as the Javascript, anchor points, etc. mentioned above. If it's an image link, don't apply a style.

The following is a quote fragment:

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template