Björn Langhof wrote:
I'd like to overwrite a native function.
Be aware that there are two variants of what you refer to as a "native
function". The first is properties of built-in objects (Object,
Function, String, etc.). The second is properties of host objects (DOM
nodes, the document object, etc.). Whilst some of the former are
read-only, most aren't. Of those that are, they are clearly specified as
such. However, attributes of the latter are at the whim of the host
itself and may vary: some properties be read-only or enumerable, for
example, in "A", but not in "B".
It's the reload()-function of the document.locati on-object.
That's a host object, therefore the possibility of success is limited.
My idea:
document.locati on.reload = function(){aler t('foo')};
So if the function document.locati on.reload() is called the alert
should appear. But it doesn't. The page is still reloaded.
Then it's reasonable to conclude that the property is read-only and your
assignment was ignored.
Any suggestions how to solve this?
Background: I write a Firefox-Extension and want to change the
behavior of a web page.
There may be a workaround for extensions, but I wouldn't know. If you
haven't already, it would be worthwhile to post to a more specialised
community that deal specifically with Firefox extensions.
[snip]
Mike