Ok, here's the breakdown...
IE doesn't recognize :hover except on anchor (<a href> or "link") elements
Now, let's say you wanted to make something have a "rollover" effect but it's NOT a link...
The fix I posted will help you to achieve this.
The first portion gets pasted into a BLANK text file and then saved as "IE_Fixes.htc"
When you save the file, type it in EXACTLY as it is above (add the ".htc" and everything)
So, that being said... Here is EVERYTHING you should paste into a new text file and save as "IE_Fixes.htc":
Code:
<PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="DoHover()" />
<PUBLIC:ATTACH EVENT="onmouseout" ONEVENT="RestoreHover()" />
<PUBLIC:ATTACH EVENT="onmousedown" ONEVENT="DoActive()" />
<PUBLIC:ATTACH EVENT="onmouseup" ONEVENT="RestoreActive()" />
<SCRIPT LANGUAGE="JScript">
function DoHover()
{ element.className += ' hover';
}
function DoActive()
{ element.className += ' active';
}
function RestoreHover()
{ element.className = element.className.replace(/\bhover\b/,'');
}
function RestoreActive()
{ element.className = element.className.replace(/\bactive\b/,'');
}
</SCRIPT>
Now, the second portion is telling IE that it should use this script for anything other than anchors (<a href> "links") that you define a ":hover" attribute to.
If you want to make a ":hover" attribute for any <img> on the page, then you would put THIS in your CSS:
Code:
img{
behavior:url('IE_Fixes.htc');
}
Now, let's say you wanted all the <img>'s on a page AND all the <div>'s on a page to have a ":hover" attribute... Then you would use THIS instead:
Code:
img, div{
behavior:url('IE_Fixes.htc');
}
Now, the third part is the actual CSS code that tells those elements what to do once hovered on...
Code:
img:hover, img.hover{
border:5px solid blue;
}
Or for the second example it would be...
Code:
img:hover, div:hover, img.hover, div.hover{
border:5px solid blue;
}
Bookmarks