Window.event.target javascript in IE 8

We needed to get the id of an event that fired and we used event.taget.id there. We tested this functionality in IE 9 and Mozilla Firefox and it was working fine. 

However when this was tested with IE 8 it was not working and it gave an error saying that the target.id is null. Strange ha…

So we did some research on this with the help of google and found out that this is not working with IE 8. In IE 8 if you want to get the Id you need to use the srcElement attribute.
So instead of event.taget.id it should be event. srcElement.id in IE 8.

The best way to get this is use the following method. 

var controlId = (event.target || event.srcElement).id

This would give you the id of the event of the attribute that fired.

Comments

Popular posts from this blog

Error message “User does not have send-as privilege.” when sending emails programmatically in CRM 2011