Thursday, June 21, 2012

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.

No comments:

Post a Comment

Retrieving Calendar of a Bookable Resource in Dynamics

There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...