IE7 onclick and :active state

Curiously, if you add an onclick event to an anchor in IE7, the anchor remains in the CSS :active state regardless of whether the javascript returns true or false. It’ll stay in this state untill you click on another element on the page.

e.g.

<!DOCTYPE html>
<html>
<head>
	<style type="text/css">
		a:active {
			background-color:red;
		}
	</style>
</head>
<body>
	<a href="#" onclick="javascript:return true;">Click me</a>
</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>