By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,719 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,719 IT Pros & Developers. It's quick & easy.

MSIE 6.0 does not support protyping with objects created with document.createElement.

P: n/a
MSIE 6.0 apparently does not support protyping with objects created
with document.createElement, while Firefox does.

I tested it by typing it into the adress bar, but it also appears to be
the case for code embedded in a HTML document. Here's a simple segment
of code to demonstrate the difference:

javascript: function myObj(){};myObj.prototype =
document.createElement('a'); var x = document.createElement('a'); var
y=new myObj(); var z= new Object(); alert(x.href) /*blank in both FF &
MSIE6 */; alert(y.href) /* blank in FF but 'undefined' in MSIE6 */;
alert(z.href) /* 'undefined' in both FF & MSIE6 */;

I wonder why that is (apart from the fact that MSIE implements JScript
and not javascript), and can anyone tell me which of both browsers is
complient with W3C standards?

regards,
Raoul

Oct 3 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"raoul" <ra****@gmail.comwrote in comp.lang.javascript:
MSIE 6.0 apparently does not support protyping with objects created
with document.createElement, while Firefox does.

I tested it by typing it into the adress bar, but it also appears to be
the case for code embedded in a HTML document. Here's a simple segment
of code to demonstrate the difference:

javascript: function myObj(){};myObj.prototype =
document.createElement('a'); var x = document.createElement('a'); var
y=new myObj(); var z= new Object(); alert(x.href) /*blank in both FF &
MSIE6 */; alert(y.href) /* blank in FF but 'undefined' in MSIE6 */;
alert(z.href) /* 'undefined' in both FF & MSIE6 */;

I wonder why that is (apart from the fact that MSIE implements JScript
and not javascript), and can anyone tell me which of both browsers is
complient with W3C standards?
W3 Consortium does not have a "recommendation" (or standard, if you will)
on ECMAscript/Javascript/Jscript.

Possibly useful reading material:

http://loadaveragezero.com/app/drx/P...ges/JavaScript
http://en.wikipedia.org/wiki/ECMAScript
http://www.piclist.com/techref/inet/.../htm/js551.htm
Oct 3 '06 #2

P: n/a

Patient Guy wrote:
"raoul" <ra****@gmail.comwrote in comp.lang.javascript:
MSIE 6.0 apparently does not support protyping with objects created
with document.createElement, while Firefox does.

I tested it by typing it into the adress bar, but it also appears to be
the case for code embedded in a HTML document. Here's a simple segment
of code to demonstrate the difference:

javascript: function myObj(){};myObj.prototype =
document.createElement('a'); var x = document.createElement('a'); var
y=new myObj(); var z= new Object(); alert(x.href) /*blank in both FF &
MSIE6 */; alert(y.href) /* blank in FF but 'undefined' in MSIE6 */;
alert(z.href) /* 'undefined' in both FF & MSIE6 */;

I wonder why that is (apart from the fact that MSIE implements JScript
and not javascript), and can anyone tell me which of both browsers is
complient with W3C standards?

W3 Consortium does not have a "recommendation" (or standard, if you will)
on ECMAscript/Javascript/Jscript.

Possibly useful reading material:

http://loadaveragezero.com/app/drx/P...ges/JavaScript
http://en.wikipedia.org/wiki/ECMAScript
http://www.piclist.com/techref/inet/.../htm/js551.htm
Thanks, but the question is rather about DOM and ECMAScript binding.
And according to this site, http://www.w3.org/DOM/, W3C does in fact
define normative binding for ECMAscript and the DOM, and it seems to be
summarized here
http://www.w3.org/TR/2000/WD-DOM-Lev...e-binding.html.
However I'm not an expert in such specifications. Rather a newbie, not
realy interested in these specifications, who is trying to make sense
of, and learning what to expect from such a specification. I just would
like know what the W3C "recommendations" say about this point. I was
therefore hoping someone here would be able to explain me a bit more.

regards,
raoul

Oct 3 '06 #3

P: n/a
raoul wrote:
Patient Guy wrote:
>"raoul" <ra****@gmail.comwrote in comp.lang.javascript:
>>MSIE 6.0 apparently does not support protyping with objects
created with document.createElement, while Firefox does.
[snip]
>>I wonder why that is (apart from the fact that MSIE implements
JScript and not javascript), and can anyone tell me which of both
browsers is complient with W3C standards?
W3 Consortium does not have a "recommendation" (or standard, if you
will) on ECMAscript/Javascript/Jscript.
[snip]
Thanks, but the question is rather about DOM and ECMAScript binding.
One was, but the reason for your original post was not.

Prototypical inheritance is a /language/ feature so behaviour in this
regard is defined by the ECMAScript specification (ECMA-262). As
previously stated, the W3C are not responsible for determining this
behaviour.
And according to this site, http://www.w3.org/DOM/, W3C does in fact
define normative binding for ECMAscript and the DOM ...
Indeed, but that's not really relevant. However, to answer your second
question, Firefox has fewer inconsistencies in relation to the DOM.
Microsoft omit some features (though in some cases, they may be
available through another interface), and implement others differently
than how the W3C defines them.

[snip]
I just would like know what the W3C "recommendations" say about this
point.
Nothing, as I hope would be clear, now. As for what the ECMAScript
specification states:

Whether or not a native object can have a host object as its
[[Prototype]] depends on the implementation.
-- 8.6.2 Internal Properties and Methods, ECMA-262 3rd Ed.

So, both behaviours are correct as it's up to a particular
implementation to decide whether host objects, such as DOM nodes, can
act as prototypes.

[snip]

Mike
Please trim quoted text when replying to only the relevant material.
Oct 4 '06 #4

P: n/a
myObj.prototype =
document.createElement('a');

???

You're setting myObj.prototype to be relevant only to the A element you
created there. Since it's a specific element, myObj wont show up in
other properties for other elements.

Oct 4 '06 #5

P: n/a
go*****@gmail.com wrote:
myObj.prototype =
document.createElement('a');

???

You're setting myObj.prototype to be relevant only to the A element
you created there.
I'm not entirely sure what you mean by that, ...
Since it's a specific element, myObj wont show up in other properties
for other elements.
.... but you have that backwards: the properties of the anchor element
are meant to be readable as properties of objects created by the myObj
constructor function[1].

In any case, the idea is likely a non-starter. The objects created from
said constructor won't actually behave like links. Assigning to the href
property, for instance, wouldn't change the property value for the
element as properties inherited from the prototype chain are only used
during reading. Upon assignment, a new property is created on the
constructed object itself. Moreover, all objects created from the myObj
constructor function will share the same anchor element, which is surely
not intended.

An alternate approach is to use augmentation:

function MyObject(base) {
base.newProperty = 'value';

return base;
}

The base argument can be any object (in this case, an anchor element),
but it /must/ be an object[2] of some sort.

Mike
Please quote relevant material when replying, and actually reply to the
right post. goulart, your message had nothing to do with what I wrote,
and should have been addressed to the OP.
[1] Note to OP: It's generally considered a good idea to give
constructor function names a capitalised initial to
distinguish them from regular functions.
[2] Values do not have properties. Trying to access a property,
either for reading or writing results in the creation of a
temporary object that is discarded before the statement
ends.
Oct 4 '06 #6

P: n/a
On 3 Oct 2006 10:56:39 -0700, "raoul" <ra****@gmail.comwrote:
>I wonder why that is (apart from the fact that MSIE implements JScript
and not javascript), and can anyone tell me which of both browsers is
complient with W3C standards?
It's nothing to do with a JScript / javascript distinction - the W3
DOM objects are host objects, so there is no requirement to expose
prototype's, it is neither required or forbidden, so both behaviour is
completely in accordance with both W3C specifications and ECMA 262 in
this respect.

Jim.
Oct 4 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.