Is it safe to modify the document Object in javascript?
I'm wondering if I can modify the document Object like this, to guarante开发者_Go百科e the existence of document.getElementsByClassName(), or if there is some limitation on modifying document in some browsers:
if(typeof document.getElementsByClassName !== 'function')
document.getElementsByClassName = function(class_name){
// Custom function
};
Yes, you can. The document
object behaves like every other object in Javascript, so it's extensible.
精彩评论