I already have a set of functions I use to extend the document (i.e. bind/unbind). So I can do stuff like: document.bind('load',someAction,{})
But it doesn’t work if I do: $('some_iframe').contentWindow.document.bind(...)
And apparently, $('some_iframe').contentWindow.document.prototype doesn’t exist.
EDIT:
Here is the code breakdown:
//the eggplant library
eggp = {
extend: function(dest, source){
for(var prop in source)
dest.prototype[prop] = source[prop];
return dest;
},
//other functions below...
bind{},
unbind{}
}
//extend the DOM
eggp.extend(Document, eggp);
//extending the iframe document DOESN'T WORK
eggp.extend(someiframe.contentWindow.document, eggp);
I’ve checked to see if someiframe.contentWindow.document is undefined, but it returns object HTMLDocument
You can’t do this, at least not in a cross-browser way. Ideally you would extend the
prototypeof theHTMLDocumentobject, but of course, IE does not have this object in the first place. As a workaround, you could create a function that creates an IFrame and automatically extends itsdocumentobject, and exclusively use that function to create your IFrames, but if the frames are already on the page, there isn’t much you can do about it short of looping through each one and extending it manually.(Assuming jQuery, insert your own library code to get all IFrames here.)
In general, though, extending built-in DOM objects is a bad idea, so you should come up with another way to do what you want.