prototype DOM creator doesn't work

W

webEater

Does anybody have good knowledge about prototype's DOM creator.
Something like this ..

var Link = new Element('a', {
href: 'layout.php'
});
document.body.appendChild(Link);

... doen't work. My Firebug shows an error: "Object cannot be created
in this context" code: "9"
I don't know what that means. Isn't there a native Element constructor
in modern Browsers like Firefox that prototype extends?

Andi
 
B

Benjamin

Does anybody have good knowledge about prototype's DOM creator.
Something like this ..

var Link = new Element('a', {
href: 'layout.php'});

document.body.appendChild(Link);

.. doen't work. My Firebug shows an error: "Object cannot be created
in this context" code: "9"
I don't know what that means. Isn't there a native Element constructor
in modern Browsers like Firefox that prototype extends?
no, you have to use
var a = document.createElement("a")
a.setAttribute("href", "layout.php")
document.body.appendChild(a)
 
W

webEater

webEater said the following on 6/26/2007 10:32 PM:


The best place to ask about prototype.js is in a prototype.js group. It
has been said that the Ruby On Rails group is a good place to ask about
it. I don't have the group link though (It is a Google Groups group).

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Thank you, Randy.

@ Benjamin:
no, you have to use
var a = document.createElement("a")
a.setAttribute("href", "layout.php")
document.body.appendChild(a)

A DOM builder is made to avoid this ;)
 
B

Benjamin

Benjamin said the following on 6/26/2007 10:38 PM:




a.href = "layout.php"

As setAttribute is buggy as a termite infested house in IE.
Why can't Microsoft just be standards compliant on something?
 
D

Darko

Benjamin said the following on 6/27/2007 10:43 PM:




Because then the anti-MS crowd would have nothing to whine about. Try
creating tables in IE and FF using DOM methods and then let me know
which is more "standards compliant" whether it be FF or IE.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Maybe you're talking about "tbody" issue or something else, I don't
know, but in 90% of things IE is not standard-compliant. If we start
making a list, you'll most certainly give up in the end, defending IE.
IE is a nightmare to everyone making JS applications according to
standards (because if one does that, they usually test it with FF) and
when they open it in IE, they find problems. Usually many. I hope,
however, we won't start such a fight here, it would be useless, and it
would be long. But sure as hell, majority of people wouldn't support
Microsoft IE.
 
D

Darko

Benjamin said the following on 6/27/2007 10:43 PM:




Because then the anti-MS crowd would have nothing to whine about. Try
creating tables in IE and FF using DOM methods and then let me know
which is more "standards compliant" whether it be FF or IE.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

I don't know what is wrong with FF and tables, maybe you're talking
about having to create TBODY or something else, I don't know, but you
have to admit that in majority of things IE isn't standards compliant
with javascript. There could be a separate thread for making the list.
Microsoft has a long monopole history, and that is the main reason why
they aren't following the standards - because they don't want to and
it's their interest not to.
 
R

RobG

Darko said the following on 6/28/2007 4:20 AM: [...]
IE is a nightmare to everyone making JS applications according to
standards (because if one does that, they usually test it with FF) and
when they open it in IE, they find problems.

Think about the opposite scenario though. If every browser acted the
exact same way where would Firefox be at? In the trash as nobody would
download a second browser just so it would behave like the one they
already have. And that would make MS extremely happy. So, how bad do
people *really* want the different browsers to behave exactly the same?

That is an interesting point. Had MS made a concerted effort to make
IE rigoursly standards compliant years ago, what support would Firefox
et al have now? All they needed to do was support all of IE's legacy
quirks in HTML 4 transitional or loose and make HTML strict support
strict W3C DOM. If they'd started that with IE 6 in say 1992 any web
site that mattered would now be standards compliant. As a bonus,
other browsers would know when to trigger an "IE DOM quirks" mode to
keep IE-specific sites in check.

But MS didn't, so now they reap what they have sown. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top