473,545 Members | 2,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript standards...

Ian
Hi there,

Can anybody tell me where I can find a standards documents like you have in
c#.

I am trying to write javascript and would like to know what standards are
i.e.

Where to put the javascript function i.e. in Head , Body or Below?

WHen to use pascal casing i.e. variables etc..

Any help would be really appreciated

Thanks

Ian
Jul 23 '05 #1
17 2048
"Ian" <ia*********@ho tmail.com> writes:
Can anybody tell me where I can find a standards documents like you have in
c#.
ECMAScript:
<URL:http://www.mozilla.org/js/language/E262-3.pdf>

DOM:
<URL:http://www.w3.org/TR/DOM-Level-2-Core/>
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/>
<URL:http://www.w3.org/TR/DOM-Level-2-Events/>
(there are a few more)
I am trying to write javascript and would like to know what standards are
i.e.

Where to put the javascript function i.e. in Head , Body or Below?
HTML:
<URL:http://www.w3.org/TR/html4/>
(Script elements can be placed in most places inside either the head
or body elements, and nowhere else).
WHen to use pascal casing i.e. variables etc..


ECMAScript is case sensitive, but there are no restrictions on the
cases used. Traditions seems to suggests Java-like casing;

normal variables and functions: camelCase
constructor functions: CapitalizedCame lCase
magic constants: ALL_CAPITALS_AN D_UNDERSCORES

Example:
---
var MAGIC_CONSTANT = 42;
function Foo(x) {
this.x = x;
}
var foo = new Foo(MAGIC_CONST ANT);
alert(foo.x);
---

The FAQ for this group is a good start for the practical application
of all these standards and specifications:
<URL:http://jibbering.com/faq/>
Likewise are the browser manufacturers' documentation:

<URL:http://devedge.netscap e.com/library/manuals/2000/javascript/1.5/reference/>
<URL:http://www.mozilla.org/docs/dom/domref/>
<URL:http://msdn.microsoft. com/library/default.asp?url =/library/en-us/script56/html/js56jsoriJScrip t.asp>
<URL:http://msdn.microsoft. com/library/default.asp?url =/workshop/author/dhtml/dhtml_node_entr y.asp>

Douglas Crockford has an overview of the language here:
<URL:http://www.crockford.c om/javascript/survey.html>

Good luck.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
On Wed, 02 Jun 2004 21:31:45 +0000, Ian wrote:
Hi there,

Can anybody tell me where I can find a standards documents like you have
in c#.


That's a funny question considering Micro$oft "embraced and enhanced"
javascript which is why there is more than one "standard".

--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #3
Ian
Cheers, great stuff!

Just what I needed... thanks

Ian
"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:u0******** **@hotpop.com.. .
"Ian" <ia*********@ho tmail.com> writes:
Can anybody tell me where I can find a standards documents like you have in c#.
ECMAScript:
<URL:http://www.mozilla.org/js/language/E262-3.pdf>

DOM:
<URL:http://www.w3.org/TR/DOM-Level-2-Core/>
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/>
<URL:http://www.w3.org/TR/DOM-Level-2-Events/>
(there are a few more)
I am trying to write javascript and would like to know what standards are i.e.

Where to put the javascript function i.e. in Head , Body or Below?


HTML:
<URL:http://www.w3.org/TR/html4/>
(Script elements can be placed in most places inside either the head
or body elements, and nowhere else).
WHen to use pascal casing i.e. variables etc..


ECMAScript is case sensitive, but there are no restrictions on the
cases used. Traditions seems to suggests Java-like casing;

normal variables and functions: camelCase
constructor functions: CapitalizedCame lCase
magic constants: ALL_CAPITALS_AN D_UNDERSCORES

Example:
---
var MAGIC_CONSTANT = 42;
function Foo(x) {
this.x = x;
}
var foo = new Foo(MAGIC_CONST ANT);
alert(foo.x);
---

The FAQ for this group is a good start for the practical application
of all these standards and specifications:
<URL:http://jibbering.com/faq/>
Likewise are the browser manufacturers' documentation:

<URL:http://devedge.netscape.com/library/...pt/1.5/referen
ce/> <URL:http://www.mozilla.org/docs/dom/domref/>
<URL:http://msdn.microsoft.com/library/de...y/en-us/script
56/html/js56jsoriJScrip t.asp> <URL:http://msdn.microsoft.com/library/de...op/author/dhtm
l/dhtml_node_entr y.asp>
Douglas Crockford has an overview of the language here:
<URL:http://www.crockford.c om/javascript/survey.html>

Good luck.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html> 'Faith without judgement merely degrades the spirit divine.'

Jul 23 '05 #4
DU
Ian wrote:
Hi there,

Can anybody tell me where I can find a standards documents like you have in
c#.

I am trying to write javascript and would like to know what standards are
i.e.

Where to put the javascript function i.e. in Head , Body or Below?

WHen to use pascal casing i.e. variables etc..

Any help would be really appreciated

Thanks

Ian


Get yourself Mozilla (say, Mozilla 1.6)

http://www.mozilla.org/
http://www.mozilla.org/start/1.6/

then go to

http://devedge.netscape.com/toolbox/sidebars/

and add in the sidebar these tabs:

# JavaScript 1.5 Guide
# JavaScript 1.5 Reference
DOM 2 References
CSS2.1
HTML 4.01

and you're ready to script. You'll be able to use the best Javascript
debugger there is (Venkman) and use Mozilla's DOM inspector: these are
very powerful tools.

DU
Jul 23 '05 #5
DU
Lasse Reichstein Nielsen wrote:
"Ian" <ia*********@ho tmail.com> writes:

Can anybody tell me where I can find a standards documents like you have in
c#.

ECMAScript:
<URL:http://www.mozilla.org/js/language/E262-3.pdf>

DOM:
<URL:http://www.w3.org/TR/DOM-Level-2-Core/>
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/>
<URL:http://www.w3.org/TR/DOM-Level-2-Events/>
(there are a few more)

I am trying to write javascript and would like to know what standards are
i.e.

Where to put the javascript function i.e. in Head , Body or Below?

HTML:
<URL:http://www.w3.org/TR/html4/>
(Script elements can be placed in most places inside either the head
or body elements, and nowhere else).

WHen to use pascal casing i.e. variables etc..

ECMAScript is case sensitive, but there are no restrictions on the
cases used. Traditions seems to suggests Java-like casing;

normal variables and functions: camelCase
constructor functions: CapitalizedCame lCase
magic constants: ALL_CAPITALS_AN D_UNDERSCORES


I think chosing meaningful, self-explanatory identifiers is much more
important than case. Also, prefixing to indicate the type of variable is
helpful when debugging. E.g.:

var strWindowName = "ProductDescrip tion";
var intTableRowsCol lection = document.getEle mentById("idTab le").rows;
function ModifyTextNode( strIdNode, strNewText)

are much more useful, clear, explicit, helpful in the short and long run
than

prod = "Product"
rows = document.getEle mentById("table ").rows;
function newtext(text, text2)

Example:
---
var MAGIC_CONSTANT = 42;
"You can create a read-only, named constant with the const keyword."
http://devedge.netscape.com/library/...t.html#1012982

DU
function Foo(x) {
this.x = x;
}
var foo = new Foo(MAGIC_CONST ANT);
alert(foo.x);
---

The FAQ for this group is a good start for the practical application
of all these standards and specifications:
<URL:http://jibbering.com/faq/>
Likewise are the browser manufacturers' documentation:

<URL:http://devedge.netscap e.com/library/manuals/2000/javascript/1.5/reference/>
<URL:http://www.mozilla.org/docs/dom/domref/>
<URL:http://msdn.microsoft. com/library/default.asp?url =/library/en-us/script56/html/js56jsoriJScrip t.asp>
<URL:http://msdn.microsoft. com/library/default.asp?url =/workshop/author/dhtml/dhtml_node_entr y.asp>

Douglas Crockford has an overview of the language here:
<URL:http://www.crockford.c om/javascript/survey.html>

Good luck.
/L

Jul 23 '05 #6
DU <dr*******@hotW IPETHISmail.com > writes:
I think chosing meaningful, self-explanatory identifiers is much more
important than case.
Definitly, but one does not preclude the other.
Also, prefixing to indicate the type of variable
is helpful when debugging. E.g.:
I'll never get used to that, though. Probably because I'm too used
to write in a language with declared types.
"You can create a read-only, named constant with the const keyword."
http://devedge.netscape.com/library/...t.html#1012982


Great for people using JavaScript 1.5, but who is that?

It's not part of ECMAScript v3, and probably only works in Gecko based
browsers (definitly doesn't work in IE 6 or Opera 7.5 - I'm not able
to check Safari or other KHTML-based browsers).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7
Lee
DU said:
I think chosing meaningful, self-explanatory identifiers is much more
important than case. Also, prefixing to indicate the type of variable is
helpful when debugging. E.g.:

var strWindowName = "ProductDescrip tion";
var intTableRowsCol lection = document.getEle mentById("idTab le").rows;
function ModifyTextNode( strIdNode, strNewText)


Taken to an extreme, prefixing can make it much more difficult to
read the code. I would suggest to use it when (a) the name doesn't
otherwise make it obvious, and (b) the variable is used more than a
few lines away from where it is assigned, and (c) the type matters.
It's usually more readable to incorporate clues into the name,
rather than use a prefix, anyway:

var windowName = "Product Description";
var today = new Date();
var todayString = today.getLocale String();
var thisMonthName = monthName[today.getMonth( )];
function modifyTextNode( nodeId, newText)

A variable that claims to be a "Name" or to be "Text" only needs to
have its type specified if it is NOT a string.

Similarly a variable named nodeId should be suitable for use as an
argument to getElementById( ), unless a nodeId is obviously something
else in the context of the code.

Jul 23 '05 #8
Ivan Marsh wrote:
On Wed, 02 Jun 2004 21:31:45 +0000, Ian wrote:
Hi there,

Can anybody tell me where I can find a standards documents like you have
in c#.


That's a funny question considering Micro$oft "embraced and enhanced"
javascript which is why there is more than one "standard".


No, there is a single standard (<url:
http://www.ecma-international.org/pu...s/Ecma-262.htm />). All
implementations of ECMAScript vary a little from the standard.

As for "embracing and extending", I recently discovered that the RegExp()
object as defined in the ECMAScript standards has no "compile()" method, yet
practically every implementation of JavaScript (including Opera and Mozilla,
which claim to be the most standards compliant browsers) support a "compile()"
method on objects created using "new RegExp()". So if Microsoft is being
blamed for "embracing and extending" JavaScript, I guess Mozilla and Opera are
guilty of this as well.

You also might be referring to the DOMs of the various browsers, which do
differ, and have since Netscape 4 introduced the proprietary <layer> tag and
it's associated entries in the DOM hierarchy (which came before Microsoft
added the document.all collection to IE 4). However, the discussion of
proprietary DOMs is irrelevant to the discussion of ECMAScript the language.

--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #9
On Fri, 04 Jun 2004 15:20:27 +0000, Grant Wagner wrote:
Ivan Marsh wrote:
On Wed, 02 Jun 2004 21:31:45 +0000, Ian wrote:
> Hi there,
>
> Can anybody tell me where I can find a standards documents like you
> have in c#.


That's a funny question considering Micro$oft "embraced and enhanced"
javascript which is why there is more than one "standard".


No, there is a single standard (<url:
http://www.ecma-international.org/pu...s/Ecma-262.htm
/>). All implementations of ECMAScript vary a little from the standard.


Standard is in quotes in my post, indicating that what I was talking about
are not true standards but the standards being used.

Embrace and enhance is how MS screws up everything it gets it's hands on
(tcp/ip, javascript, java, etc...).

Javascript pre-dates the ECMA standard and Netscape/Mozilla are
responsible for the ECMA standard existing.

--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #10

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

Similar topics

12
1920
by: Howard Kaikow | last post by:
Yesterday, I decided to try Firefox. I've encountered a behavior that is either a bug in Firefox or a bug in my Javascript code. I'll try to explain the problem, hoping that this newsgroup can (in)validate my Javascript code. First, I'll describe the purpose of the Javascript code. I often have a need to post a URL to something at my own...
8
3634
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
0
7496
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7428
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7784
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6014
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5354
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5071
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3485
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.