Reputation: 347
I have code snippet document.attachEvent("onclick", func);
whenever there is a click event I am getting this error JavaScript runtime error: Object doesn't support property or method 'attachEvent'
I am using Jquery 1.2.6 version .
Upvotes: 0
Views: 95
Reputation: 1075825
attachEvent
was a Microsoft innovation which has been replaced by the DOM2 standard addEventListener
, even in Microsoft's most recent browsers.
So change
document.attachEvent("onclick", func);
to
document.addEventListener("click", func, false);
Of course, that will fail on older IE.
Or, as you say you're using jQuery, you can sidestep the whole issue:
$(document).bind("click", func); // Antiquated jQuery
I would also strongly recommend you use an up-to-date version of jQuery, as v1.2.6 is ancient in web terms. If you use something recent, then you'd use:
$(document).on("click", func); // Current jQuery
Upvotes: 1