Javascript| link | conversion
The CSS property selector allows you to selectively control the link style, such as having all external links add a small icon to identify it as an external link.
But using CSS has drawbacks:
1, only support Firefox and other Web standards to support a good browser.
2, can only judge the link, cannot judge anchor point or JavaScript. If encountered <a href= "javascript:void (0);" > Can do nothing about it.
This can be combined with JS to complete, first write a style:
A.other:link,a.other:visited,a.other:active
{
Background:url ("External.gif") no-repeat top right;
padding-right:15px;
}
Then write a JS, but JS to take into account the diversity of links, such as the above mentioned JavaScript, anchor points and so on. If it is a picture link, do not apply the style.
<script type= "Text/javascript" >
Window.onload = function ()
{
var alist = document.getElementsByTagName (' a ');
var icount = alist.length;
for (var i = 0;i<icount;i++)
{
if (!chkmylink (alist[i].href,alist[i].innerhtml))
{
Alist[i].classname = ' other ';
}
}
}
S is the link url,innerhtml is the link text
function Chkmylink (s,innerhtml)
{
if (Innerhtml.replace (/^\s*/, ""). Match (/^\var reg =/^http\:\/\//gi;
if (S.match (REG))
{
reg =/^http\:\/\/www.webjx.com/gi;
if (S.match (REG))
{
return true;
}
Else
{
return false;
}
}
return true;
}
</script>
Now you can see the effect.