I have some JavaScript code that defines a function getElementsByAttribute as follows:
Object.prototype.getElementsByAttribute = function(attr)
Adding things to Object.prototype is a really bad idea. It will be added to every object, and that will cause unintended behavior, I guarantee it.
Simply define your function and decorate it onto whatever objects you need dynamically.
IE DOM elements aren't normal Javascript objects and do not inherit prototypes as you would expect.
http://perfectionkills.com/whats-wrong-with-extending-the-dom/