473,326 Members | 2,588 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,326 software developers and data experts.

Extend HTMLElement

How do you extend HTMLElement? Why can't you just do

HTMLElement.prototype.foo=function() {
alert( 'foo' );
}

I assume HTMLElement belongs to some kind of namespace, but darn if I
can find anything that tells me anything about it.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #1
1 3118
Christopher Benson-Manica wrote:
How do you extend HTMLElement? Why can't you just do

HTMLElement.prototype.foo=function() {
alert( 'foo' );
}
You can, but only in some user agents. Host objects are not required
to act like native objects. In some respects, IE is particularly
restrictive in the way in which it treats host objects to the point of
being, in my opinion, unreasonable.

It would be safer to create a function that accepts a reference to an
element.
I assume HTMLElement belongs to some kind of namespace, [...]


In user agents that provide it, it will be a property of the global
object.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

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

Similar topics

2
by: Jason Keirstead | last post by:
Is there a way I can add a setter/getter to the HTMLElement prototype in internet explorer? This, for example, works fine in Mozilla: HTMLElement.prototype.__defineSetter__("foobar", function...
10
by: Jerzy Karczmarczuk | last post by:
Gurus, before I am tempted to signal this as a bug, perhaps you might convince me that it should be so. If I type l=range(4) l.extend() l gives , what else... On the other hand, try
2
by: Boobie | last post by:
I switched to using this function to create element: ---------------------------------------------------- function elem(name, attrs, style, text) { var e = document.createElement(name); if...
3
by: Vin | last post by:
Hi, I have a webbrowser control in my winform. There is an html in the webbrowser which has a table, and many child <tr>s and <td>s inside it. I want to delete a specific <tr> node completely...
1
by: cweeks | last post by:
Dev env: VS 2005 C# Express, .Net Framework 2.0 I am trying to programmatically select an item in a listbox on a web page. The first thing I do is go through and de-select any selected items. ...
0
by: JS | last post by:
I'm trying to figure out how to draw a rectangle around an HtmlElement in the WebBrowser control. Does anybody know how to do this? The behavior I'm trying to replicate is that of the Internet...
1
by: AMDRIT | last post by:
Hello Everyone, We have a production WinForms Application that uses a WebBrowser to display readonly data. In the html document we have SPAN elements that facilitate menu selections. We also...
3
by: jacobstr | last post by:
I've noticed Object.extend used in a few different ways and I'm having trouble distinguishing why certain usages apply to a given situation. On line 804 Ajax.Base is defined as follows: ...
5
by: marchaos | last post by:
I'm trying to override the native HTMLElement.addEventListener in firefox so that I can do some extra things. I know it's possible to add methods to the HTMLElement prototype and for them to be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.