473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Overwrite native function

Hello.

I'd like to overwrite a native function. It's the reload()-function of
the document.location-object. My idea:

document.location.reload = function(){alert('foo')};

So if the function document.location.reload() is called the alert should
appear. But it doesn't. The page is still reloaded.

Any suggestions how to solve this?

Background: I write a Firefox-Extension and want to change the behavior
of a web page.

A possible workaround is to trigger the onUnload-event of the
document-element. But this is also called when the page is left without
a reload.

Thanks for your help.

Björn
Nov 10 '06 #1
1 2483
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.location-object.
That's a host object, therefore the possibility of success is limited.
My idea:

document.location.reload = function(){alert('foo')};

So if the function document.location.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
Nov 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff | last post by:
Could someone help me out with automatically overwriting files when using a MS Project VB macro? As you can see, I have the file saving to native format, then to a HTML file. When it goes to save...
2
by: Torsten Mohr | last post by:
Hi, is there some description available to overwrite the import hook? By googling i found out so far that i need to overwrite __builtins__.__import__ with something else. Can i also do this...
3
by: David Baumgarten | last post by:
I am trying to download a file from a ftp server and if the file already exists to overwrite it. Here is my code: FtpGetFile(hConnection, "1.pdf", FLocation & "\Temp\" & "1.pdf", False, 1, 0,...
11
by: Florian Loitsch | last post by:
I'm currently writing a JS->Scheme compiler (which, using Bigloo, automatically yields a JS->C, JS->JVM, JS->.NET compiler), and have a question concerning the function-parameters: According to...
0
by: BlackCat_DNA_XY | last post by:
Hello, After switching from VC6 to .NET, I was looking for the class wizard to overwrite messages and functions and could not find where the option has been placed. Now, I found it, by looking...
3
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following...
3
by: Kai Kuehne | last post by:
Hi list! It is possible to overwrite only one function with the property-function? x = property(getx, setx, delx, 'doc') I just want to overwrite setx, but when I set the others to None, I...
2
by: hzgt9b | last post by:
I know how to overwrite a function. Normally this is what I would do: function someFunction() { /* orig definition here */ } //later in the execution stream I would do... someFunction = function...
2
by: Bob Altman | last post by:
Hi all, We have a native class modeled after the System::Exception class, and all exceptions that we throw derive from this class. For now this class is quite simple: just Description and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.