| re: question on Document.prototype modifications
"Joshie Surber" <joshiesurber@gmail.com> writes:
[color=blue][color=green]
>> will this function be available in the already loaded frames[/color]
>
> The frames will have different document.objects from the frameset page,
> so the simple answer is no. If you were to say
> frames[0].document.prototype then it would apply, but only as long as
> the frame was showing the same page. As soon as a new page is loaded a
> different document object is created, so you would need to redefine
> document.prototype for each page viewed within the frameset.[/color]
I don't think this is quite right.
[Ecma/Java]Script follows the prototype chain, which means if
'document.doSomething()' does not exist (that is: 'doSomething()' is
not a property of 'document'), it will next check into
'document.prototype'.
So, if you have access to the Document type (and it's prototype) in
order to modify it then yes, all your documents should show the
changes.
The following illustrates what I just said (in spidermonkey, just
changed the prompt's '>' to ':' to avoid quoting confusion in newsreaders):
-------------snip------------
aundro@paddy:~$ js
js: function Test () {}
js: var zzz = new Test ();
js: Test.prototype.showStuff = function () {print ("Hy there");}
function () {
print("Hy there");
}
js: zzz.showStuff();
Hy there
js:
aundro@paddy:~$
-------------snip------------
Arnaud |