473,396 Members | 1,997 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.

Inheriting from an HTML element in IE


Hello,

I've recently been developping a google-maps-like api.
Firstly, I started development under Firefox, but I now need to run it
under Internet Explorer, and I'm running into a little bit of
trouble..

With firefox, a "MapView" object actually subclasses a HTMLDivElement, as
follows:

----8<----
MapView.superclass = HTMLDivElement;
MapView.prototype = document.createElement ("div");
MapView.prototype.constructor = MapView;
----8<----

but that does not work with Internet Explorer, as it does not propose
the same (W3C) DOM api as Mozilla-based browsers.

I've been looking after the type of element to subclass under IE, or a
different subclassing mechanism, but without success. Can anyone point
me some reference documentation, or propose any kind of solution?

Many thanks in advance!

Cheers,
Arnaud
Sep 6 '05 #1
2 2545


aundro wrote:
MapView.superclass = HTMLDivElement;
MapView.prototype = document.createElement ("div");
MapView.prototype.constructor = MapView; but that does not work with Internet Explorer, as it does not propose
the same (W3C) DOM api as Mozilla-based browsers.
It is debatable whether the W3C DOM for its ECMAScript binding requires
an implementation to expose stuff like a HTMLDivElement constructor
function or its prototype.
In general there is not anything in the specification and the ECMAScript
binding which suggests that with a few exceptions where static stuff
like Node.ELEMENT_NODE is explicitly mentions which then obviously
requires the implementation to expose Node first to be able to expose
Node.ELEMENT_NODE.
I've been looking after the type of element to subclass under IE, or a
different subclassing mechanism, but without success. Can anyone point
me some reference documentation, or propose any kind of solution?


IE on Windows allows you to implement behaviors for elements and bind
them to elements with a CSS rule so you would encapsulate your stuff in
a behavior and bind e.g.
div { behavior: url(yourBehavior.htc); }
This is not subclassing but what you do with Mozilla is usually not
called subclassing either as ECMAScript as implemented by JavaScript 1.x
in Mozilla/Netscape or by JScript in IE does not know any classes or
class based inheritance.

As for documentation of behaviors and HTCs (HTML components) for IE:
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/behaviors_node_entry.asp>
<http://msdn.microsoft.com/library/default.asp?url=/workshop/components/htc/reference/htcref.asp>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 6 '05 #2

Hi,

Martin Honnen <ma*******@yahoo.de> writes:
aundro wrote:
MapView.superclass = HTMLDivElement;
MapView.prototype = document.createElement ("div");
MapView.prototype.constructor = MapView;
but that does not work with Internet Explorer, as it does not propose
the same (W3C) DOM api as Mozilla-based browsers.


It is debatable whether the W3C DOM for its ECMAScript binding
requires an implementation to expose stuff like a HTMLDivElement
constructor function or its prototype.
In general there is not anything in the specification and the
ECMAScript binding which suggests that with a few exceptions where
static stuff like Node.ELEMENT_NODE is explicitly mentions which then
obviously requires the implementation to expose Node first to be able
to expose Node.ELEMENT_NODE.


Indeed, I shouldn't have relied on the fact that Mozilla exposes those
constructors in the first time..
I've been looking after the type of element to subclass under IE, or a
different subclassing mechanism, but without success. Can anyone point
me some reference documentation, or propose any kind of solution?
IE on Windows allows you to implement behaviors for elements and bind
them to elements with a CSS rule so you would encapsulate your stuff
in a behavior and bind e.g.
div { behavior: url(yourBehavior.htc); }


Well, the purpose of behaviors seems to be to divert the default
behavior of an element of a given type (EG: div).
What I need is to create a new type of element/object that would
'inherit' (*) all the DIV's behaviour (receive events, take the
expected screen estate, ...), but to which (to the prototype of which,
actually) I want to add some functions specific to a map API.

It seems I could do that with the HTCs, but doesn't it seem a little
overkill in this case? Maybe I could consider an alternative: make a
function for creating my MapView objects, like

---
createMapView(width, height)
---

which would just return the result of a
document.createElement("div");, to which I'd have added all the
functions specific to a map view. Something like this:

-------

// IE version
createMapView4IE(width, height) {

var d = document.createElement ("div");
d.addLayer = ___my_predefined_add_layer;
d.panNorth = ___my_predefined_pan_north;
d.panSouth = ___my_predefined_pan_south;
d.resize = ___my_predefined_resize;
...
return d;
}
-------

What do you think? Wouldn't it be simpler?
(*) I know this is not real subclassing :)
This is not subclassing but what you do with Mozilla is usually not
called subclassing either as ECMAScript as implemented by JavaScript
1.x in Mozilla/Netscape or by JScript in IE does not know any classes
or class based inheritance.
As for documentation of behaviors and HTCs (HTML components) for IE:
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/behaviors_node_entry.asp>
<http://msdn.microsoft.com/library/default.asp?url=/workshop/components/htc/reference/htcref.asp>
Many, many thanks for the pointers, and for your concern!
Martin Honnen

Best regards,

Arnaud

Sep 6 '05 #3

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

Similar topics

1
by: richardlane | last post by:
Hi, basic question here - I'm struggling with the transfer from asp to asp.net a bit, especially in seeing the 'bigger picture' of how things are best structured. I have a website made up...
2
by: Peter Bates | last post by:
Hi, I'm just getting used to XSDObjectGen and i have the following question. Can i use a class inherited from a class generated by XSDObjectGen with XmlSerialize? Specifically, I have many...
11
by: Noah Coad [MVP .NET/C#] | last post by:
How do you make a member of a class mandatory to override with a _new_ definition? For example, when inheriting from System.Collections.CollectionBase, you are required to implement certain...
8
by: Anthony Williams | last post by:
Morning all, I'm having a wee problem with a project I'm working on at the moment. I'm leading my company into producing a website, based upon Web Standards, which will be created using XHTML...
0
by: z. f. | last post by:
Hi, I'm not so familiar with control inheriting, but what i need is very simple (should be) and requires only deep knowledge with implementing control inheritence. is it possible (might someone...
24
by: toton | last post by:
Hi, I want to have a vector like class with some additional functionality (cosmetic one). So can I inherit a vector class to add the addition function like, CorresVector : public...
1
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi, I have a behavior file called ScrollPos.htc, which is supposed to maintain the scroll position of a datagrid within a div tag. In my html I have <%@ Page Language="C#"...
1
by: Nathan Sokalski | last post by:
I am creating a control in which I inherit from the DropDownList. The only method that I override is RenderContents. Here is my basic code: Public Class StatesDropDownList : Inherits DropDownList...
3
by: Raymond Martineau | last post by:
I have the following code segment for a class intended to split output between cout and a file: class SplitStream : public std::streambuf { std::streambuf *x; public: SplitStream() {
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
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.