Fiddling with HTML and JavaScript, I know that `createElement()' should be used to create a new HTML element, and it is only possible to do so with XHTML documents. So, I was surprised when I found out that I can do `new Option([text[, value[, defaultSelected[, selected]]]])' to create a new HTML Option element to be added to an HTML Select element. The next question that followed will be: who standardizes the arguments to the constructor of an HTML Option element.
I had navigating through http://w3.org and http://w3schools.com in vain to find the answer when I also found someone in the same situation: http://www.coderanch.com/t/120551/HTML-JavaScript/Option-Constructor. Unfortunately, the answer is not there.
But, googling a bit further landed me on http://docs.sun.com/source/816-6408-10/option.htm. It says that an HTML Option element can be created either by the constructor or by the HTML tag. Browsing through the other elements described on http://docs.sun.com/source/816-6408-10/contents.htm under `Chapter 1 Objects, Methods, and Properties' of `Part 1 Object Reference', I found that most of the other elements can be created only by the corresponding HTML tags and only the HTML Option element that differs by allowing a construction from its constructor.
Now reading the history of JavaScript on http://en.wikipedia.org/wiki/Javascript, it is clear that JavaScript originated from Netscape and Sun. Considering the fact that http://w3.org and http://w3schools.com make no allusion to the construction of an HTML Option element through its constructor, I conclude that the construct `new Option([text[, value[, defaultSelected[, selected]]]])' is not the standard way to construct an HTML Option element in favor to `createElement()', and that the standard that standardizes the arguments of the construct can be found in the Sun website. It is titled `Client-Side JavaScript Reference'.
Keywords: javascript create new option element constructor argument createElement
My Conclusion is Correct
Hi Ho!
Since I would like to know whether or not my conclusion was correct, I started a forum thread in W3Schools for a faster feedback.
The discussion on http://w3schools.invisionzone.com/index.php?showtopic=22981 indicates that my conclusion is correct.
Best regards,
Eus (FSF member #4445)
In this digital era, where computing technology is pervasive,
your freedom depends on the software controlling those computing devices.
Join free software movement today!
It is free as in freedom, not as in free beer!
Join: http://www.fsf.org/jf?referrer=4445