Code: Select all
<a href=""><img src=""/></a>
I have used the whole cancelBubble = true and returnValue = false but I can't seem to figure out how to get the <a> in IE (7).
anyone with some insight workarounds?
Moderator: General Moderators
Code: Select all
<a href=""><img src=""/></a>
Code: Select all
<element onclick="alert(this.id);" />Code: Select all
<element onclick="my_function(event);" />But, and this is only preference at this point, separating out your JavaScript from your HTML is a better practice.JAB Creations wrote:This should work just fine in IE...
...then replace alert with a custom function...and alert the id...Code: Select all
<element onclick="alert(this.id);" />
...if IE is giving you the img element then use the W3C DOM to access it's parentNode.Code: Select all
<element onclick="my_function(event);" />
Good tutorial for JavaScript nodes here: http://www.howtocreate.co.uk/tutorials/ ... /dombasics
Code: Select all
window.onload = function() {
var a_tags = document.getElementsByClassName('class_name');
// For legit browsers
a_tags.addEventListener( 'click', functionName , false );
// For IE
a_tags.attachEvent( 'onclick', functionName )
}