473,796 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Overwrite native function

Hello.

I'd like to overwrite a native function. It's the reload()-function of
the document.locati on-object. 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.

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 2511
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
Nov 11 '06 #2

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

Similar topics

0
2680
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 the HTML, it always gives me an overwrite verification msg. for which I have to click "OK." I'd like to avoid having to click and just have it overwrite. Here's the pertinent portion of the macro: FileSave FileSaveAs...
2
3053
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 with a C function that is provided when using an embedded python interpreter? So my own C program provides this and when linking with python.lib the function is overwritten?
3
3682
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, 0) If file does not exists then this returns true and downloads file. If file already exists then this returns false and doesnt download file.
11
2475
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 the spec (10.1.6) the activation-object already contains the the parameters-object when the variables are instantiated (10.1.3). The question is now: does a parameter "parameters" overwrite the "parameters"-object or not? All three implementations...
0
990
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 to properties and clicking on the icon Messages on top of Properties. I also found place where the function can be overwritten with a wizard by clicking on the .cpp file, properties and Overrides button (a green cube). But, the function I wish to...
3
3673
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 runtime error, " Attempting to call into managed code without transitioning out first. Do not attempt to run managed code inside low-level native extensibility points, such as the vectored exception handler, since doing so can cause corruption...
3
1970
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 can't read and del the member. Any ideas or is this not possible? Thank you! Kai
2
6466
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 () { /* overwrite function definition */ } The above works fine for me even when someFunction is originally defined in a seperate frame other than the code that overwrites it (obviously on the same domain). What I don't know how to-do is...
2
2968
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 InnerException public members. One of these days I'll dig into how to implement a StackTrace property (I assume that this is possible using something like dbghelp.dll, but I've never had the time to look into it). I've recently written a managed...
0
9530
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6793
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.