HTML Text Highlighter


The Code
6/13/2005 2:43:26 AM



Highlighting text with everything except Internet Explorer (IE) is a breeze, all you need to do is: a:hover{color: red;}.

But for (IE, things get a little tougher. See (IE tries to make their Web Development tools (i.e. Visual Studio, FrontPage) work with previous versions of (IE as well as deprecated HTML.

So instead of using an a tag, we have to use a .htc file, which means HTML Component. Component, well not really, just some JavaScript to do the dynamic text instead of CSS. So some typical code looks like this.

<component>
<attach for=element event=onmouseover handler=hig_lite />
<attach for=element event=onmouseout handler=low_lite />
<script type=text/javascript>
function hig_lite()
{
	element.style.color = #369
}
function low_lite()
{
	element.style.color = silver
}
</script>
</component>

Then to call the JavaScript code, you do a: p{behavior: url(../stylesheets/hover.htc);}. Interested in a live demo other than this page, check this out and go ahead and view the code, that's why it's there.

Joe Gakenheimer



Comment on: 'HTML Text Highlighter' Has Been Closed!