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

New FAQ Version for review

P: n/a
There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>

The changes/modifications to date are:

2.3 Corrected "span" to "spam".
2.3 Updated with a note about not posting copyrighted material.
2.3 Removed paragraph about Google Groups.
2.3 Para 5 Added note about code being executable as transmitted.
2.4 Made an LI list of the answers.
2.7 Updated with a reference to the MS group for JScript.
3.1 Updated to include Fifth Edition.
3.2 (WSH) added to the .wsh newsgroup reference.
3.2 Added links to the MS Debugger and Documentation.
3.2 Updated to refer to microsoft.public.scripting.wsh rather than
Google Groups
4.4 Updated with new links on cookies.
4.6 Updated to refer to 4.7 Wording questionable?
4.9 Retitled "How do I find the size of the browser canvas area?"
4.13 Slightly reworded.
4.20 Updated to refer to the delay in setTimeout and setInterval
4.43 Updated to reflect the new location of the JS Console in Opera
5.1 Updated to request draft proposal for an FAQ Entry.

There are probably some changes I failed to notate when doing it. I
still have 24 more FAQENTRY requests to sort through and then the
discussions on the FAQ since Bart has been posting a section a day.

I think that 3.2 is getting sufficiently lengthy enough that it might
benefit from being moved to a page of it's own.

Thoughts and comments are welcome.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 26 '06 #1
Share this Question
Share on Google+
89 Replies


P: n/a
Randy Webb wrote:
There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>

The changes/modifications to date are:
<snip>
4.9 Retitled "How do I find the size of the browser canvas area?"
I take it you did not buy Lee's justification that the question that
actually is frequently asked is about "window" size, even if the
information required, and the answers given, actually relate to client
area size?
4.13 Slightly reworded.
<snip>

I never thought that there was anything wrong with the wording of 4.13
as it was, but while you are enumerating situations where just reading -
contrl.value - is problematic don't <IINPUT type="file"elements
qualify?

Richard.
Nov 26 '06 #2

P: n/a
Richard Cornford said the following on 11/26/2006 6:51 PM:
Randy Webb wrote:
>There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>

The changes/modifications to date are:
<snip>
>4.9 Retitled "How do I find the size of the browser canvas area?"

I take it you did not buy Lee's justification that the question that
actually is frequently asked is about "window" size, even if the
information required, and the answers given, actually relate to client
area size?
I can buy that justification, it is just a misleading title is all. It
is now reworded again:

"How do I find the size of the window/browser canvas area?"

With this note:

While it is often asked about window size, what is more relevant is the
"canvas area" of the browser.
>4.13 Slightly reworded.
<snip>

I never thought that there was anything wrong with the wording of 4.13
as it was,
The wording, as it was, implied there was One exception, then it says
there is another exception. It was just misleading to me is all and if
it gets to where the way it is now is misleading, it can be changed back.
but while you are enumerating situations where just reading -
contrl.value - is problematic don't <IINPUT type="file"elements
qualify?
Sure it does, and there is now a small snippet there. I was going to
find a section of <URL:
http://www.jibbering.com/faq/faq_notes/form_access.htmlthat dealt with
File Inputs but it doesn't appear anywhere in that document.

I am pretty sure the wording of Third Exception leaves a lot to be
desired and is open to be changed again.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 27 '06 #3

P: n/a
Randy Webb wrote:
There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>
[...]
Thoughts and comments are welcome.
Can you update the CSS? The current FAQ looks very, very dated. The
format of the "Javascript Best Practices" page is pretty good[1],
perhaps that (or something similar) can be adopted without too much
effort?

Maybe Matt would volunteer, if not, I'm happy to do it.
1. The text is set too small and the dashed borders are kitsch ;-),
otherwise it's simple, clean and reasonably modern.
--
Rob

Nov 27 '06 #4

P: n/a
RobG said the following on 11/27/2006 12:20 AM:
Randy Webb wrote:
>There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>
[...]
>Thoughts and comments are welcome.

Can you update the CSS?
Sure can, its a work in progress :)
The current FAQ looks very, very dated. The format of the "Javascript
Best Practices" page is pretty good[1], perhaps that (or something
similar) can be adopted without too much effort?
It would just be a matter of creating a file call faq.css and uploading it.
Maybe Matt would volunteer, if not, I'm happy to do it.
Save the index.html and faq.css files locally, modify them and email
them to cl****@ctvea.net and I can upload it and get it reviewed.
<URL: http://jibbering.com/faq/newfaq/index.html>
<URL: http://jibbering.com/faq/newfaq/faq.css>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 27 '06 #5

P: n/a
Randy Webb said the following on 11/26/2006 5:39 PM:
There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>
There is a new upload there that reflects some changes based on Richards
thoughts, Evertjan's comma and a section 4.44 entitle "What is AJAX?"

Any thoughts, comments or corrections appreciated.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 27 '06 #6

P: n/a
Randy Webb wrote:
Randy Webb said the following on 11/26/2006 5:39 PM:
There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>

There is a new upload there that reflects some changes based on Richards
thoughts, Evertjan's comma and a section 4.44 entitle "What is AJAX?"

Any thoughts, comments or corrections appreciated.
Thanks for the good work !

--
Bart

Nov 27 '06 #7

P: n/a
Randy Webb wrote:
Richard Cornford said the following on 11/26/2006 6:51 PM:
>Randy Webb wrote:
<snip>
>I never thought that there was anything wrong with the
wording of 4.13 as it was,

The wording, as it was, implied there was One exception,
then it says there is another exception.
<snip>

No it did not. It gave two examples of exceptions form an indefinite
set.

Richard.
Nov 27 '06 #8

P: n/a
Richard Cornford said the following on 11/27/2006 6:36 PM:
Randy Webb wrote:
>Richard Cornford said the following on 11/26/2006 6:51 PM:
>>Randy Webb wrote:
<snip>
>>I never thought that there was anything wrong with the
wording of 4.13 as it was,
The wording, as it was, implied there was One exception,
then it says there is another exception.
<snip>

No it did not.
Yes it did.
It gave two examples of exceptions form an indefinite set.
The set of form elements and the ways of accessing them is not an
indefinite set, nor are the problems associated with it. So a subset of
a fixed set can't be an indefinite set.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 27 '06 #9

P: n/a
Randy Webb wrote:
Randy Webb said the following on 11/26/2006 5:39 PM:
>There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>

There is a new upload there that reflects some changes based on Richards
thoughts, Evertjan's comma and a section 4.44 entitle "What is AJAX?"
Nit on spelling in the AJAX explanation, the object is named
"XMLHttpRequest" and not "XMLHTTPRequest".

You could also add links to the Mozilla documentation
<http://developer.mozilla.org/en/docs/XMLHttpRequest>
and the IE documentation of the object
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/obj_xmlhttprequest.asp>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/63409298-0516-437d-b5af-68368157eae3.asp>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 28 '06 #10

P: n/a
Martin Honnen said the following on 11/28/2006 12:21 PM:
Randy Webb wrote:
>Randy Webb said the following on 11/26/2006 5:39 PM:
>>There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>

There is a new upload there that reflects some changes based on
Richards thoughts, Evertjan's comma and a section 4.44 entitle "What
is AJAX?"

Nit on spelling in the AJAX explanation, the object is named
"XMLHttpRequest" and not "XMLHTTPRequest".

You could also add links to the Mozilla documentation
<http://developer.mozilla.org/en/docs/XMLHttpRequest>
and the IE documentation of the object
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/obj_xmlhttprequest.asp>

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/63409298-0516-437d-b5af-68368157eae3.asp>
Is it worth using the non-framed URL for the MSDN articles? It makes it
even longer for the FAQ:

<URL:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/obj_xmlhttprequest.asp?frame=true&hidetoc=true>

I tried this one:

<URL:
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_xmlhttprequest.asp>

And it takes you to the page but then MS automatically puts it back in
the frameset with the tree view :\

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 28 '06 #11

P: n/a
Randy Webb wrote:
Is it worth using the non-framed URL for the MSDN articles?
Hard to answer in general, I prefer having the toc tree on the left to
be able to navigate easily to e.g. objects/properties/methods. But I am
usually sitting in front of a desktop system with a large enough monitor
not to be hurt by frames taking up space. A laptop user might have other
preferences.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 28 '06 #12

P: n/a
In comp.lang.javascript message <37********************@telcove.net>,
Sun, 26 Nov 2006 17:39:09, Randy Webb <Hi************@aol.comwrote:
>There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>
It (unlike 8.1) lacks a clear statement as to who maintains it.

Also, it's not clear what the present status of the FAQ Notes is.
Are they still maintained?
Are they abandonware, (c) RC?
Are they detached parts of the FAQ, similarly maintained, (c)
newsgroup?

IMHO, each Note should be annotated with the name of its author, its
maintainer if different, and its date; the link to the index page should
be dejargonised and repeated at the top, and the Notes index page should
enlarge a little on such matters. The final link at the top of Notes
Index, to zipped Notes & FAQ, needs consideration.

<FAQENTRY>FAQ section 1, or thereabouts, should contain a link to each
individual Note, as a list.
</FAQENTRY>

If they are not now maintained, the FAQ should make that clear.
>4.20 Updated to refer to the delay in setTimeout and setInterval
The added sentence includes "generally". ISTM that, for the common case
where the requested delay is a multiple of the tick interval, IE6 in
WinXP does not do that; and if IE6 (so, probably, IE7?) does not do it,
can "generally" be right?

The delay is not *caused* by the difference.

"The delay ... may exceed ... (browsers differ)."
TIDY checker reports missing <liin 4.29. Probably four are missing
(see issue 8.1, 4.29).
2.1 : Subject now ungrammatical.
4.12 Subject : but parseInt('09') does not give an error. It gives, as
it should, a Number of value 0.

"4.12 Why does K = parseInt('09') set K to 0?

Function parseInt(S, B) accepts two arguments, string S and base B; the
first character (leading whitespace excepted) in S which in that
position cannot be part of a base-B number terminates number reading.

If B is not given : S with leading "0x" or "0X" is read as Hexadecimal,
else S with leading "0" is read as Octal, otherwise S is read as
Decimal. Generally, it is better to use unary + : K = +S ."

N.B. When an entry's Subject is a question, the entry's body should
*always* explicitly answer that question. It should usually, but should
not only, present a solution to any implied problem. If necessary,
change the Subject.
4.16 How do I trim whitespace ...

String "aaa zzz" contains trimmable whitespace; but the entry ignores
that case. ASCII should read Unicode.
Count : "enviroment" 3, "environment" 1.

>I think that 3.2 is getting sufficiently lengthy enough that it might
benefit from being moved to a page of it's own.
Can one have confidence in an author who, seemingly having lived for
many years in a nominally English-speaking country, and in spite of
frequently-presented examples in this newsgroup, still apparently
believes "it's" to be a genitive? Also FAQ 4.44.

It's a good idea to read the newsgroup and its old FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
<URL:http://www.jibbering.com/faq/ Old RC FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 28 '06 #13

P: n/a

Randy Webb wrote:
RobG said the following on 11/27/2006 12:20 AM:
Randy Webb wrote:
There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>
[...]
Thoughts and comments are welcome.
Can you update the CSS?
[...]
>
Save the index.html and faq.css files locally, modify them and email
them to clj...net and I can upload it and get it reviewed.
OK, done that.

Mac users (Safari users in particular) should change their monospace
font to Monaco 14pt, the default Courier (new) 13pt is way too small on
all browsers and monitors.
--
Rob

Nov 28 '06 #14

P: n/a
Randy Webb wrote:
There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>
<snip>
Thoughts and comments are welcome.
Below are a few.

Peter

------------

There seem to be two leading spaces at the start of each code example.

------------

In section 4.9
When using IE6 with in CSS1Compat mode (with a Formal DOCTYPE)
Would this be clearer as the following?

When using IE6 with in CSS1Compat mode (i.e. with a Formal DOCTYPE)

------------

In section 4.13
In HTML documents, named forms may be referred to as named properties of the document.forms collection
It seems to me that named forms are also available as properties of the
document object.

------------

In section 4.15
Using the DOM and Microsoft's innerHTML extension
This could be interpreted as innerHTML is only available in IE. Could
"Microsoft's" be replaced with "the non-standard but widely
implemented"

The code example in this section seems to be for browsers without
function literals. To which browsers does this cater? Does this example
deserve updating?

------------

In Section 4.18

The last sentance in section 4.18 could be moved to 4.44

------------

In Section 4.22

The function name "Random" is capitalized which is usually reserved for
constructor functions. Perhaps this should be lower case

The featured code in the yellow box doesn't answer the section's title
question. The actual answer is added like an after thought.
gives a random number in the range 0..(x-1); Random(N)+1 for [1..N]
The range notation is not consistent in this sentence. I suggest the
use standard range notation: [1, N] and [1, N) or [1, N-1]
------------

Could sections 4.25 and 4.39 should be close together or merged?

------------

In Section 4.31

Could a mention of preloading images be added. Something like

(new Image()).src = "http://example.com/maui.gif"

If the image is served with correct headers when this JavaScript runs
then the first time the roll over is used it won't be slow, at least in
some browsers.

Perhaps mentioning that sliding images can be used instead like RobG (I
believe) mentioned within the last weeks.

------------

In Section 4.34
Mozilla, Safari, and the Windows version of IE (and Opera 7.6+)
I think Opera deserves to be outside of parentheses. Something like
this with the correct version numbers. (I'll research the correct
numbers if someone doesnt know off the top of their more knowing head.)
Something more like this...

Mozilla (NN6+, Firefox, Ice Weasle etc), Opera 7.6+, Safari, the
Windows version of IE versions 5+, and some other browsers

------------

In Section 4.39
There are two equivalent ways to access properties
I suggest the removal of the word equivalent

------------

In Section 4.43

The Firebug extension in Firefox is so valuable I think it is worth a
mention. Firebug is just going to version 1.0

http://www.getfirebug.com/

------------

In Section 4.44

Ajax only has one capital letter. It may be an acronym but Ajax was
also a Greek God or something.

http://www.adaptivepath.com/publicat...ves/000385.php

Nov 29 '06 #15

P: n/a
RobG said the following on 11/28/2006 6:53 PM:
Randy Webb wrote:
>RobG said the following on 11/27/2006 12:20 AM:
>>Randy Webb wrote:
There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>
[...]
Thoughts and comments are welcome.
Can you update the CSS?
[...]
>Save the index.html and faq.css files locally, modify them and email
them to clj...net and I can upload it and get it reviewed.

OK, done that.

Mac users (Safari users in particular) should change their monospace
font to Monaco 14pt, the default Courier (new) 13pt is way too small on
all browsers and monitors.
Check your email for an alternative email address. After checking it
from some other email addresses I don't think ctvea.net likes the file
attachments. It wouldn't even let me send myself an attachment. What a
service that is there!

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 29 '06 #16

P: n/a

Randy Webb wrote:
[...]
Check your email for an alternative email address. After checking it
from some other email addresses I don't think ctvea.net likes the file
attachments. It wouldn't even let me send myself an attachment. What a
service that is there!
Thanks, done that. I may not have properly attached the files.
--
Rob

Nov 29 '06 #17

P: n/a
RobG said the following on 11/28/2006 8:39 PM:
Randy Webb wrote:
[...]
>Check your email for an alternative email address. After checking it
from some other email addresses I don't think ctvea.net likes the file
attachments. It wouldn't even let me send myself an attachment. What a
service that is there!

Thanks, done that. I may not have properly attached the files.
I am not sure it was you. I tried sending myself an email with an
attachment and the email went through but without the attachment. I have
to call them and find out what happened and why.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 29 '06 #18

P: n/a
Peter Michaux said the following on 11/28/2006 8:28 PM:
Randy Webb wrote:
>There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>

<snip>
>Thoughts and comments are welcome.

Below are a few.

Peter

------------

There seem to be two leading spaces at the start of each code example.
Fixed. I am not sure how it happened but the file that processes the XML
file was adding a leading space. The original has that leading space
added but I don't see it in the FAQ itself so not sure what is going on
with that one.
------------

In section 4.9
>When using IE6 with in CSS1Compat mode (with a Formal DOCTYPE)

Would this be clearer as the following?

When using IE6 with in CSS1Compat mode (i.e. with a Formal DOCTYPE)
Not sure but it is added.
------------

In section 4.13
>In HTML documents, named forms may be referred to as named properties of the document.forms collection

It seems to me that named forms are also available as properties of the
document object.
They are. But the FAQ was stressing using the FORMS collection.
------------

In section 4.15
>Using the DOM and Microsoft's innerHTML extension

This could be interpreted as innerHTML is only available in IE. Could
"Microsoft's" be replaced with "the non-standard but widely
implemented"
Not sure why it was worded that way in the past, sure there was a reason
but it's modified. If there was a good reason that is still there now, I
am sure we will hear about it :)
The code example in this section seems to be for browsers without
function literals. To which browsers does this cater? Does this example
deserve updating?
What do you propose updating it to? And, what is wrong with what is
there now?
------------

In Section 4.18

The last sentance in section 4.18 could be moved to 4.44
I'm not too sure that sentence should appear at all except in 4.44 so I
moved the last sentence, along with the link, to 4.44 as an alternative
to the XMLHttpRequest Object.
------------

In Section 4.22

The function name "Random" is capitalized which is usually reserved for
constructor functions. Perhaps this should be lower case
Almost except that it uses Math.random() in the code. IIRC it was
capitalized to prevent confusion with Math.random()
The featured code in the yellow box doesn't answer the section's title
question. The actual answer is added like an after thought.
True :\
>gives a random number in the range 0..(x-1); Random(N)+1 for [1..N]

The range notation is not consistent in this sentence. I suggest the
use standard range notation: [1, N] and [1, N) or [1, N-1]
Modified.
------------

Could sections 4.25 and 4.39 should be close together or merged?
They are closely related but different. One deals with forms with []
characters in the name while the other deals with Bracket Notation in
general. Of which I have never agreed with terming it "illegal
characters" as [] are perfectly valid in HTML attributes. The problem
comes when trying to access them via script. But, it was agreed to the
wording with regards to being illegal.

The problem with merging them is historical links in the archives. Right
now I want to try to update what is there and get it live. Then it will
be time to try to go through this again with another layout/format after
there is an updated FAQ on-line.
------------

In Section 4.31

Could a mention of preloading images be added.
I have always thought it should mention it. The word "preload" nor
"pre-load" appear in the FAQ anywhere and typically when people ask
about that entry they are generally wanting to know how to preload
images. Whenever a preload entry has come up someone always beckons
about "It might not work in browser KYJ so don't do it".

The last line in that entry implies that headers are the only way to
overcome that problem and I have never seen a browser where preloading
them using new Image() didn't do the trick.

Personally, I think the whole entry needs to be retitled and re-written
as a "How do I preload images" entry along with the notes/links about
headers.
Something like
(new Image()).src = "http://example.com/maui.gif"

If the image is served with correct headers when this JavaScript runs
then the first time the roll over is used it won't be slow, at least in
some browsers.

Perhaps mentioning that sliding images can be used instead like RobG (I
believe) mentioned within the last weeks.
------------

In Section 4.34
>Mozilla, Safari, and the Windows version of IE (and Opera 7.6+)

I think Opera deserves to be outside of parentheses. Something like
this with the correct version numbers. (I'll research the correct
numbers if someone doesnt know off the top of their more knowing head.)
I moved the code line there to a box of it's own. Even in the old
version it starts at the end of the paragraph.
Something more like this...

Mozilla (NN6+, Firefox, Ice Weasle etc), Opera 7.6+, Safari, the
Windows version of IE versions 5+, and some other browsers
Updated, as you have it. If you can find version numbers for the first
level of each browser that supports it I can add the version numbers to it.
Section 4.38:

I added a link to <URL: http://www.ajaxtoolbox.comand removed the link
to Laurents Java page. In this thread:

<URL:
http://groups-beta.google.com/group/comp.lang.javascript/browse_thread/thread/81e4f8d6ab9a4b17/0f859a94afc95598?lnk=gst&q=Laurent+FAQ+Java&rnum=1 #0f859a94afc95598>

Laurent recommended against using it so it's removed.

------------

In Section 4.39
>There are two equivalent ways to access properties

I suggest the removal of the word equivalent
Done. They have never been equivalent and never will :)
------------

In Section 4.43

The Firebug extension in Firefox is so valuable I think it is worth a
mention. Firebug is just going to version 1.0

http://www.getfirebug.com/
Added. It probably needs to be reworded but it is there.
------------

In Section 4.44

Ajax only has one capital letter. It may be an acronym but Ajax was
also a Greek God or something.

http://www.adaptivepath.com/publicat...ves/000385.php
Ajax has been so many things nobody is sure anymore :) But, it is changed.

Thank you.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 29 '06 #19

P: n/a
Dr J R Stockton said the following on 11/28/2006 7:43 AM:
In comp.lang.javascript message <37********************@telcove.net>,
Sun, 26 Nov 2006 17:39:09, Randy Webb <Hi************@aol.comwrote:
>There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>

It (unlike 8.1) lacks a clear statement as to who maintains it.
It is added back but it didn't make a hill of beans to me so I removed
it. But, it's back in there now.
Also, it's not clear what the present status of the FAQ Notes is.
Are they still maintained?
What has indicated that they aren't?
Are they abandonware, (c) RC?
Are they detached parts of the FAQ, similarly maintained, (c)
newsgroup?
<shrug>

Do you have a proposed Notes page to add? If so, URL to it and it will
get reviewed, uploaded, and a link added to the Notes page.
IMHO, each Note should be annotated with the name of its author, its
maintainer if different, and its date;
The date, perhaps. But Author and Maintainer? The FAQ is for
information, not personal glorification.
the link to the index page should be dejargonised and repeated at the top,
and the Notes index page should enlarge a little on such matters.
What is so "jargonized" about the link and what is a proposed re-wording?
The final link at the top of Notes Index, to zipped Notes & FAQ, needs
consideration.
<FAQENTRY>FAQ section 1, or thereabouts, should contain a link to each
individual Note, as a list.
</FAQENTRY>
Why? There is already a TOC to the Notes.
If they are not now maintained, the FAQ should make that clear.
I have seen nothing to indicate they aren't maintained.
>
>4.20 Updated to refer to the delay in setTimeout and setInterval

The added sentence includes "generally". ISTM that, for the common case
where the requested delay is a multiple of the tick interval, IE6 in
WinXP does not do that; and if IE6 (so, probably, IE7?) does not do it,
can "generally" be right?

The delay is not *caused* by the difference.

"The delay ... may exceed ... (browsers differ)."
TIDY checker reports missing <liin 4.29. Probably four are missing
(see issue 8.1, 4.29).
Fixed the LI issue. It was the result of an errant search/replace.
>
2.1 : Subject now ungrammatical.
Whatever.
>
4.12 Subject : but parseInt('09') does not give an error. It gives, as
it should, a Number of value 0.
"4.12 Why does K = parseInt('09') set K to 0?

Function parseInt(S, B) accepts two arguments, string S and base B; the
first character (leading whitespace excepted) in S which in that
position cannot be part of a base-B number terminates number reading.

If B is not given : S with leading "0x" or "0X" is read as Hexadecimal,
else S with leading "0" is read as Octal, otherwise S is read as
Decimal. Generally, it is better to use unary + : K = +S ."
I won't have this argument with you again. It has been had in the past
and when it was had you simply ducked around the argument.
N.B. When an entry's Subject is a question, the entry's body should
*always* explicitly answer that question. It should usually, but should
not only, present a solution to any implied problem. If necessary,
change the Subject.
There is nothing wrong with the Subject though.
4.16 How do I trim whitespace ...

String "aaa zzz" contains trimmable whitespace; but the entry ignores
that case. ASCII should read Unicode.
Proposed alternative?
>
Count : "enviroment" 3, "environment" 1.

>I think that 3.2 is getting sufficiently lengthy enough that it might
benefit from being moved to a page of it's own.

Can one have confidence in an author who, seemingly having lived for
many years in a nominally English-speaking country, and in spite of
frequently-presented examples in this newsgroup, still apparently
believes "it's" to be a genitive? Also FAQ 4.44.
Mea bouws doun befoor yer majisty an beags fer fergiveness fer mi
transgreshuns.

NGFY

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 29 '06 #20

P: n/a
Hi Randy,
The code example in this section seems to be for browsers without
function literals. To which browsers does this cater? Does this example
deserve updating?

What do you propose updating it to? And, what is wrong with what is
there now?
It doesn't have semicolons at the ends of all the lines. I can't take
it! :S

Well maybe nothing wrong with it at all. In fact, it may work in more
browsers than with function literals. However it looks old and no one
bothers programming that way anymore, do they? Using the Function
constructor is leading in the direction of using eval where it is not
necessary.

I have no clue but I would guess that since the Function constructor
takes string arguments that it would parse the strings at run time and
be slower during execution than using a function literal which would be
parsed during compile time.

I don't know if the goal is to have getRef in the global space or not.
I doubt a closure is appropriate to this FAQ question so to keep it
looking simple for the FAQ maybe just this

var getRef,
dynWrite;

if (document.getElementById) {
getRef = function(id) {return document.getElementById(id);} ;
} else if (document.all) {
getRef = function(id) {return document.all(id);};
}

if (getRef) {
dynWrite = function(id, s) {getRef(id).innerHTML=s; return true;};
} else {
dynWrite = function() {return false;};
}

(Can't help it, I have to remove those uppercase function names.)

I know the repetition in defining getRef could be removed but perhaps
at the cost of clarity.

Given IE 5 has getElementById isn't it time to stop all of this
document.all stuff anyway and shove those browsers down the degredation
path with NS 4 like the current example has done. In which case the
entire example becomes

var dynWrite;
if (document.getElementById) {
dynWrite = function(id, s) {document.getElementById(id).innerHTML=s;
return true;}
} else {
dynWrite = function(){return false;}
}

This example still displays feature detection but assumes innerHTML
which is not in the character of c.l.j.

// first call to dynWrite initializes it
var dynWrite = function(id, s) {
var el;
if (document.getElementById &&
el = document.getElementById(id) &&
el.innerHTML) {
dynWrite = function(id, s) {
document.getElementById(id).innerHTML=s;
return true;
}
} else {
dynWrite = function() {return false;};
}
return dynWrite(id, s);
};

Ok maybe I've gone off the deep end but if c.l.j. regulars are going to
go on about feature detection then maybe this is the necessary version.
:)

------------

In Section 4.22

The function name "Random" is capitalized which is usually reserved for
constructor functions. Perhaps this should be lower case

Almost except that it uses Math.random() in the code. IIRC it was
capitalized to prevent confusion with Math.random()
If lower case "random" is out then how about "chaos" or the more boring
"rand" for the function name? I really think that upper case function
names should be reserved for constructors. But hey, that's just me.

Could sections 4.25 and 4.39 should be close together or merged?

They are closely related but different. One deals with forms with []
characters in the name while the other deals with Bracket Notation in
general. Of which I have never agreed with terming it "illegal
characters" as [] are perfectly valid in HTML attributes. The problem
comes when trying to access them via script. But, it was agreed to the
wording with regards to being illegal.

The problem with merging them is historical links in the archives. Right
now I want to try to update what is there and get it live. Then it will
be time to try to go through this again with another layout/format after
there is an updated FAQ on-line.
Ok. I do think they should be close so I'll try to remember this one so
I can bring it up again and make sure the nice faq volunteer isn't
bored.

------------

In Section 4.31

Could a mention of preloading images be added.

I have always thought it should mention it. The word "preload" nor
"pre-load" appear in the FAQ anywhere and typically when people ask
about that entry they are generally wanting to know how to preload
images. Whenever a preload entry has come up someone always beckons
about "It might not work in browser KYJ so don't do it".

The last line in that entry implies that headers are the only way to
overcome that problem and I have never seen a browser where preloading
them using new Image() didn't do the trick.

Personally, I think the whole entry needs to be retitled and re-written
as a "How do I preload images" entry along with the notes/links about
headers.
I imagine this will be revisited later.
Mozilla, Safari, and the Windows version of IE (and Opera 7.6+)
I think Opera deserves to be outside of parentheses. Something like
this with the correct version numbers. (I'll research the correct
numbers if someone doesnt know off the top of their more knowing head.)

I moved the code line there to a box of it's own. Even in the old
version it starts at the end of the paragraph.
Something more like this...

Mozilla (NN6+, Firefox, Ice Weasle etc), Opera 7.6+, Safari, the
Windows version of IE versions 5+, and some other browsers

Updated, as you have it. If you can find version numbers for the first
level of each browser that supports it I can add the version numbers to it.
Randy, I'm not worth trusting for information yet, am I? I'm still just
the new kid.

I just downloaded four versions of NN6 and the first version to support
my test XHR test was 6.2

The Apple website says Safari 1.2 is the first with XHR

If someone took the time to determine Opera 7.6 was the first Opera
with XHR I believe them.

I don't know a thing about Ice Weasle except the name is hilarious and
I might not be able to stop laughing if I was using it. Especially if I
could see the Ice Weasle logo.

Perhaps the following would be appropriate

Mozilla (Netscape Navigator 6.2+, Firefox), Opera 7.6+, Safari 1.2+,
the Windows version of Internet Explorer 5+, and some other browsers.
Peter

Nov 29 '06 #21

P: n/a
Peter Michaux said the following on 11/29/2006 3:10 AM:
Hi Randy,
>>The code example in this section seems to be for browsers without
function literals. To which browsers does this cater? Does this example
deserve updating?
What do you propose updating it to? And, what is wrong with what is
there now?

It doesn't have semicolons at the ends of all the lines. I can't take
it! :S
Ahhh, the semicolons... :)

<snip>
Given IE 5 has getElementById isn't it time to stop all of this
document.all stuff anyway and shove those browsers down the degredation
path with NS 4 like the current example has done. In which case the
entire example becomes
If IE4 support is dropped then the entire entry answer becomes
document.getElementById(yourElementId).innerHTML = newHTML;

Does it not? And I didn't think IE4 needed to be covered even when NN4
was dropped and definitely don't think it should be included now. People
using IE4 now can't use 90% of the web anyway so not a lot in the FAQ is
of much use to them for any reason other than historical reasons.
Ok maybe I've gone off the deep end but if c.l.j. regulars are going to
go on about feature detection then maybe this is the necessary version.
:)
if (document &&
document.getElementById &&
document.getElementById('someElement') &&
document.getElementById('someElement').innerHTML)
{
document.getElementById(someElement').innerHTML = "some HTML here"
}
>>------------

In Section 4.22

The function name "Random" is capitalized which is usually reserved for
constructor functions. Perhaps this should be lower case
Almost except that it uses Math.random() in the code. IIRC it was
capitalized to prevent confusion with Math.random()

If lower case "random" is out then how about "chaos" or the more boring
"rand" for the function name? I really think that upper case function
names should be reserved for constructors. But hey, that's just me.
It is so widely known that there isn't really any benefit in changing
it. Maybe randomNumber(x).

<snip>
>>------------

In Section 4.31

Could a mention of preloading images be added.
I have always thought it should mention it. The word "preload" nor
"pre-load" appear in the FAQ anywhere and typically when people ask
about that entry they are generally wanting to know how to preload
images. Whenever a preload entry has come up someone always beckons
about "It might not work in browser KYJ so don't do it".

The last line in that entry implies that headers are the only way to
overcome that problem and I have never seen a browser where preloading
them using new Image() didn't do the trick.

Personally, I think the whole entry needs to be retitled and re-written
as a "How do I preload images" entry along with the notes/links about
headers.

I imagine this will be revisited later.
Absolutely. Preloading seems to come up pretty often. Either directly or
indirectly but I don't recall seeing any one post and ask "Why are my
rollovers so slow?"
>>>Mozilla, Safari, and the Windows version of IE (and Opera 7.6+)
I think Opera deserves to be outside of parentheses. Something like
this with the correct version numbers. (I'll research the correct
numbers if someone doesnt know off the top of their more knowing head.)
I moved the code line there to a box of it's own. Even in the old
version it starts at the end of the paragraph.
>>Something more like this...

Mozilla (NN6+, Firefox, Ice Weasle etc), Opera 7.6+, Safari, the
Windows version of IE versions 5+, and some other browsers
Updated, as you have it. If you can find version numbers for the first
level of each browser that supports it I can add the version numbers to it.

Randy, I'm not worth trusting for information yet, am I? I'm still just
the new kid.
If you are downloading and installing browsers then why would anybody
have a reason not to believe you until you give them a reason? I tend to
give people some benefit unless they are posting questions that can be
answered in 30 seconds in the archives, then I get my typically ranting
attitude.
I just downloaded four versions of NN6 and the first version to support
my test XHR test was 6.2

The Apple website says Safari 1.2 is the first with XHR

If someone took the time to determine Opera 7.6 was the first Opera
with XHR I believe them.

I don't know a thing about Ice Weasle except the name is hilarious and
I might not be able to stop laughing if I was using it. Especially if I
could see the Ice Weasle logo.
<URL: http://www.gnu.org/software/gnuzilla/>

He's kinda cute actually.....
Perhaps the following would be appropriate

Mozilla (Netscape Navigator 6.2+, Firefox), Opera 7.6+, Safari 1.2+,
the Windows version of Internet Explorer 5+, and some other browsers.
I left the name Ice Weasel in it because it's a Debian browser which is
a different OS but it's based on Mozilla. From what I have read about it
though, it is simply Firefox for the Debian Package with a different
name/logo.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 29 '06 #22

P: n/a
In comp.lang.javascript message
<ek*******************@news.demon.co.uk>, Mon, 27 Nov 2006 23:36:42,
Richard Cornford <Ri*****@litotes.demon.co.ukwrote:
>Randy Webb wrote:
>Richard Cornford said the following on 11/26/2006 6:51 PM:
>>Randy Webb wrote:
<snip>
>>I never thought that there was anything wrong with the
wording of 4.13 as it was,

The wording, as it was, implied there was One exception,
then it says there is another exception.
<snip>

No it did not. It gave two examples of exceptions form an indefinite
set.
We cannot expect a Merkin to be able to understand English.

By "One exception ..." ... "Another exception ..." you clearly suggested
that at least one other exception was possible or likely or certain.

Randy asserts that there are exactly three exceptions - which is
egg-on-his-face if anyone demonstrates another,
But, you being a Failed FAQ writer, it ill behoves you to criticise one
who is at least trying.

It's a good idea to read the newsgroup and its old FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
<URL:http://www.jibbering.com/faq/ Old RC FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 29 '06 #23

P: n/a
In comp.lang.javascript message <H6********************@telcove.net>,
Wed, 29 Nov 2006 00:19:38, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/28/2006 7:43 AM:
>In comp.lang.javascript message <37********************@telcove.net>,
Sun, 26 Nov 2006 17:39:09, Randy Webb <Hi************@aol.comwrote:
>>There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>
It (unlike 8.1) lacks a clear statement as to who maintains it.

It is added back but it didn't make a hill of beans to me so I removed
it. But, it's back in there now.
>Also, it's not clear what the present status of the FAQ Notes is.
Are they still maintained?

What has indicated that they aren't?
What has indicated that they are?
> Are they abandonware, (c) RC?
Are they detached parts of the FAQ, similarly maintained, (c)
newsgroup?

<shrug>

Do you have a proposed Notes page to add? If so, URL to it and it will
get reviewed, uploaded, and a link added to the Notes page.
>IMHO, each Note should be annotated with the name of its author, its
maintainer if different, and its date;

The date, perhaps. But Author and Maintainer? The FAQ is for
information, not personal glorification.
An author should be prepared to put his name to his work, and to receive
comment both favourable and unfavourable.

>the link to the index page should be dejargonised and repeated at the
top, and the Notes index page should enlarge a little on such
matters.

What is so "jargonized" about the link and what is a proposed re-wording?
>The final link at the top of Notes Index, to zipped Notes & FAQ,
needs consideration.
<FAQENTRY>FAQ section 1, or thereabouts, should contain a link to each
individual Note, as a list.
</FAQENTRY>

Why? There is already a TOC to the Notes.
Because we do not all have continuous access to the Net/Web, but those
of us who have sensibly chosen our News access method do, when using our
computers, have permanent access to the FAQ as posted to News.
>If they are not now maintained, the FAQ should make that clear.

I have seen nothing to indicate they aren't maintained.
I have seen nothing to indicate that they are.

> 2.1 : Subject now ungrammatical.

Whatever.
Even the weakest knowledge of English grammar should suffice to tell
that the change is to an error. The plural noun requires a plural verb
form here. It is a change (in falsely-dated 9.0) from 8.1.
> 4.12 Subject : but parseInt('09') does not give an error. It gives,
as
it should, a Number of value 0.
"4.12 Why does K = parseInt('09') set K to 0?
Function parseInt(S, B) accepts two arguments, string S and base B;
the
first character (leading whitespace excepted) in S which in that
position cannot be part of a base-B number terminates number reading.
If B is not given : S with leading "0x" or "0X" is read as
Hexadecimal,
else S with leading "0" is read as Octal, otherwise S is read as
Decimal. Generally, it is better to use unary + : K = +S ."

I won't have this argument with you again. It has been had in the past
and when it was had you simply ducked around the argument.
I don't recall arguing about whether parseInt("09") gives an error. It
gives Number 0, as is right and proper. The newsgroup regulars are in
general agreement, ISTM, that unary + is good.
>N.B. When an entry's Subject is a question, the entry's body should
*always* explicitly answer that question. It should usually, but should
not only, present a solution to any implied problem. If necessary,
change the Subject.

There is nothing wrong with the Subject though.
Eh? "*The* Subject"? That is a general remark, applying to all entries
in S.4.

The present Subject of 4.12 is wrong in that no error is given (though
the result may not match what was wanted). For a complete response to
the "Why" one must state that the first character which cannot be part
of the number causes termination, so that "09" is treated as "0" which
is then read /* in octal */ and yields Number 0.

>4.16 How do I trim whitespace ...
String "aaa zzz" contains trimmable whitespace; but the entry
ignores
that case. ASCII should read Unicode.

Proposed alternative?
If you cannot write, at full speed, a .Replace() using a RegExp to
reduce multiple embedded whitespace to a single space, then see any
tutorial on RegExps. The non-RegExp part of 4.16 is no longer worth
keeping.

BTW, the FAQ lacks a general RegExps section. Such a section should not
be long, but should refer to their great utility and provide a couple of
links. You should know where to look for a longer treatment.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zipTimo Salmi's Turbo Pascal FAQ.
Nov 29 '06 #24

P: n/a
In comp.lang.javascript message <pv********************@telcove.net>,
Wed, 29 Nov 2006 04:06:09, Randy Webb <Hi************@aol.comwrote:
>
>Given IE 5 has getElementById isn't it time to stop all of this
document.all stuff anyway and shove those browsers down the degredation
path with NS 4 like the current example has done. In which case the
entire example becomes

If IE4 support is dropped then the entire entry answer becomes
document.getElementById(yourElementId).innerHTM L = newHTML;

Does it not? And I didn't think IE4 needed to be covered even when NN4
was dropped and definitely don't think it should be included now.
People using IE4 now can't use 90% of the web anyway so not a lot in
the FAQ is of much use to them for any reason other than historical
reasons.
Well, 99% of the Web is rubbish, blatantly commercial, or both. But, of
the rest, over 95% of what I wanted to see was accessible to IE4.

Those who write pages for use by impoverished organisations, maybe in
the Third World, may still want to support older systems.

And one must not fall into the same trap as a certain computer supplier,
whose Web site (including order-placing part) was only accessible to
those with computers too new to need replacing.

However, the code cited above lacks one advantage of DynWrite : it is,
wherever used, longer.

function DineRite(ID, HTML) {
document.getElementById(ID).innerHTML = HTML }

is the way to go, so that in the code one sees the job each time and not
the mechanism.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
For news:borland.*, use their server newsgroups.borland.com ; but first read
Guidelines <URL:http://www.borland.com/newsgroups/guide.htmlff. with care.
Nov 29 '06 #25

P: n/a
Dr J R Stockton wrote:
Richard Cornford wrote:
>>Randy Webb wrote:
>>Richard Cornford said the following on 11/26/2006 6:51 PM:
Randy Webb wrote:
<snip>
>>>I never thought that there was anything wrong with the
wording of 4.13 as it was,

The wording, as it was, implied there was One exception,
then it says there is another exception.
<snip>

No it did not. It gave two examples of exceptions form an
indefinite set.

We cannot expect a Merkin to be able to understand English.
That would you depend on what you mean by "Murkin". My dictionary says;
"a hairpiece for the pubic area. [Origin uncertain]". If I had been
aware of their existence I would not have expected them to understand
English.

I do expect citizens of the United States to understand English. I may
yet be disappointed but those I have conversed with to date don't seem
to have any serious difficulty doing so.
By "One exception ..." ... "Another exception ..." you
Mike Winter wrote the wording for that version of that entry.
clearly suggested that at least one other exception was
possible or likely or certain.

Randy asserts that there are exactly three exceptions -
which is egg-on-his-face if anyone demonstrates another,
Any attempt to list all risks becoming extended. I seem to recall some
early Opera versions asking the user for permission to allow scripts to
access <input type="password"fields (I don't know why as if
cross-domain scripting is properly excluded that should not be a
security issue).
But, you being a Failed FAQ writer, it ill behoves you to
criticise one who is at least trying.
<snip>

I was not criticising Randy. I was hoping he might ask for a second
opinion on his interpretation, as I suspect that the first 5 people he
asked would reveal a majority in favour of my interpretation.

Richard.
Nov 30 '06 #26

P: n/a
Richard Cornford said the following on 11/29/2006 8:01 PM:
Dr J R Stockton wrote:
<snip>
>By "One exception ..." ... "Another exception ..." you

Mike Winter wrote the wording for that version of that entry.
The wording just seemed odd to me was all. Might have just been me
<shrug>. With a third exception being file inputs, would it be better to
change it to something like this:

Some exceptions would be:

Or, is the list sufficient enough to move it a Notes section?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 30 '06 #27

P: n/a
Dr J R Stockton said the following on 11/29/2006 6:51 PM:
In comp.lang.javascript message <pv********************@telcove.net>,
Wed, 29 Nov 2006 04:06:09, Randy Webb <Hi************@aol.comwrote:
>>Given IE 5 has getElementById isn't it time to stop all of this
document.all stuff anyway and shove those browsers down the degredation
path with NS 4 like the current example has done. In which case the
entire example becomes
If IE4 support is dropped then the entire entry answer becomes
document.getElementById(yourElementId).innerHTM L = newHTML;

Does it not? And I didn't think IE4 needed to be covered even when NN4
was dropped and definitely don't think it should be included now.
People using IE4 now can't use 90% of the web anyway so not a lot in
the FAQ is of much use to them for any reason other than historical
reasons.

Well, 99% of the Web is rubbish, blatantly commercial, or both. But, of
the rest, over 95% of what I wanted to see was accessible to IE4.
I said nothing about your personal browsing habits. I said they can't
use 90% of the web.
Those who write pages for use by impoverished organisations, maybe in
the Third World, may still want to support older systems.
Then let them search the archives or ask how to support an older system.
By that reasoning, the FAQ entry should cover NN4 as well......
However, the code cited above lacks one advantage of DynWrite : it is,
wherever used, longer.

function DineRite(ID, HTML) {
document.getElementById(ID).innerHTML = HTML }

is the way to go, so that in the code one sees the job each time and not
the mechanism.
That one is shorter but it suffers a flaw that my code dosen't.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 30 '06 #28

P: n/a
Dr J R Stockton said the following on 11/28/2006 3:01 PM:
In comp.lang.javascript message
<ek*******************@news.demon.co.uk>, Mon, 27 Nov 2006 23:36:42,
Richard Cornford <Ri*****@litotes.demon.co.ukwrote:
>Randy Webb wrote:
>>Richard Cornford said the following on 11/26/2006 6:51 PM:
Randy Webb wrote:
<snip>
>>>I never thought that there was anything wrong with the
wording of 4.13 as it was,

The wording, as it was, implied there was One exception,
then it says there is another exception.
<snip>

No it did not. It gave two examples of exceptions form an indefinite
set.

We cannot expect a Merkin to be able to understand English.

By "One exception ..." ... "Another exception ..." you clearly suggested
that at least one other exception was possible or likely or certain.
Randy asserts that there are exactly three exceptions - which is
egg-on-his-face if anyone demonstrates another,
No. The entry doesn't say "The only three exceptions are.." It said
"Three exceptions are". I thought you would realize that but evidently
your hatred of anything American is clouding your judgement.
But, you being a Failed FAQ writer, it ill behoves you to criticise one
who is at least trying.
Richard is far from a "Failed FAQ writer". To date, Richard has written
approximately 10 kazillion times as much in the FAQ as you have. All I
have seen you do is post about once a week requesting something be added
yet I have seen only one or two posts where you actually offer any kind
of proposed entry. It is typically you just whining about nothing
getting done. Well, not a lot can get done when either Richard or myself
has to spend time weeding through your non-productive FAQ requests in
order to get something done. Maybe you should check the post from Peter
and use it as a guideline to future requests.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 30 '06 #29

P: n/a
Dr J R Stockton said the following on 11/29/2006 6:23 PM:
In comp.lang.javascript message <H6********************@telcove.net>,
Wed, 29 Nov 2006 00:19:38, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/28/2006 7:43 AM:
>>In comp.lang.javascript message <37********************@telcove.net>,
Sun, 26 Nov 2006 17:39:09, Randy Webb <Hi************@aol.comwrote:
There is an updated version of the FAQ at:
<URL: http://jibbering.com/faq/newfaq/>
It (unlike 8.1) lacks a clear statement as to who maintains it.

It is added back but it didn't make a hill of beans to me so I removed
it. But, it's back in there now.
>>Also, it's not clear what the present status of the FAQ Notes is.
Are they still maintained?

What has indicated that they aren't?

What has indicated that they are?
You are one of the most evasive people I have ever tried to have a
conversation with. The Notes section is maintained. There is nothing to
indicate they aren't. If you have some solid reasonable reason for
thinking they aren't then please state it. If you intend to continue to
be evasive about it then please drop it.

<snip>
>>IMHO, each Note should be annotated with the name of its author, its
maintainer if different, and its date;

The date, perhaps. But Author and Maintainer? The FAQ is for
information, not personal glorification.

An author should be prepared to put his name to his work, and to receive
comment both favourable and unfavourable.
You don't need an author's name to comment about code. The only reason
for wanting a name is to critique the person. Second, any code in the
FAQ or Notes can't easily be changed by the person writing it. If there
is a problem with code in either the FAQ or the Notes then only three
people - to the best of my knowledge - have the ability and access to
change it. Directing comments to the author becomes moot. In short - I
am not inclined to go through and comment who wrote what code in the FAQ
or the Notes pages.
>>The final link at the top of Notes Index, to zipped Notes & FAQ,
needs consideration.
<FAQENTRY>FAQ section 1, or thereabouts, should contain a link to each
individual Note, as a list.
</FAQENTRY>
I won't comment on the wisdom of putting an FAQENTRY marker in a
conversation that is being conducted in a thread directly addressing
updating the FAQ and especially when the conversation is being conducted
with the person that would be reacting to that FAQENTRY request.
>Why? There is already a TOC to the Notes.

Because we do not all have continuous access to the Net/Web, but those
of us who have sensibly chosen our News access method do, when using our
computers, have permanent access to the FAQ as posted to News.
I am not going to change the TOC to the Notes to satisfy your wants and
desires based on you not being connected at all times. If you want "easy
access" to the Notes then do it the same way you have access to the FAQ.
Download the .zip file, unzip it, and you have total 100% access to them.
>> 4.12 Subject : but parseInt('09') does not give an error. It gives, as
it should, a Number of value 0.
"4.12 Why does K = parseInt('09') set K to 0?
Function parseInt(S, B) accepts two arguments, string S and base B; the
first character (leading whitespace excepted) in S which in that
position cannot be part of a base-B number terminates number reading.
If B is not given : S with leading "0x" or "0X" is read as Hexadecimal,
else S with leading "0" is read as Octal, otherwise S is read as
Decimal. Generally, it is better to use unary + : K = +S ."

I won't have this argument with you again. It has been had in the past
and when it was had you simply ducked around the argument.

I don't recall arguing about whether parseInt("09") gives an error. It
gives Number 0, as is right and proper. The newsgroup regulars are in
general agreement, ISTM, that unary + is good.
Then what is your proposed re-wording of the Subject of 4.12?
>>N.B. When an entry's Subject is a question, the entry's body should
*always* explicitly answer that question. It should usually, but should
not only, present a solution to any implied problem. If necessary,
change the Subject.

There is nothing wrong with the Subject though.

Eh? "*The* Subject"? That is a general remark, applying to all entries
in S.4.
No it wasn't, but believe what you want.
>>4.16 How do I trim whitespace ...
String "aaa zzz" contains trimmable whitespace; but the entry ignores
that case. ASCII should read Unicode.

Proposed alternative?

If you cannot write, at full speed, a .Replace() using a RegExp to
reduce multiple embedded whitespace to a single space, then see any
tutorial on RegExps. The non-RegExp part of 4.16 is no longer worth
keeping.
Once again, you want something changed but you don't want to propose an
alternative?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 30 '06 #30

P: n/a
Dr J R Stockton wrote:
In comp.lang.javascript message <H6********************@telcove.net>,
Wed, 29 Nov 2006 00:19:38, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/28/2006 7:43 AM:
[snip]
>>"4.12 Why does K = parseInt('09') set K to 0?

Function parseInt(S, B) accepts two arguments, string S and base
B; the first character (leading whitespace excepted) in S which
in that position cannot be part of a base-B number terminates
number reading.

If B is not given : S with leading "0x" or "0X" is read as
Hexadecimal, else S with leading "0" is read as Octal, otherwise
S is read as Decimal. Generally, it is better to use unary + : K
= +S ."

I won't have this argument with you again. It has been had in the
past and when it was had you simply ducked around the argument.

I don't recall arguing about whether parseInt("09") gives an error.
That wasn't the argument.
It gives Number 0, as is right and proper.
No, it /may/ return zero. It may also return 9, which is correct, too.
Opera, for instance, returns the latter.

The argument began from (what I believe to be) the sensible conclusion
that the second, base argument should be passed to the function. Your
counterargument was that such an action prevents users from entering
hexadecimal numbers of the form 0xHH, which would otherwise receive
treatment as base-16 numbers.

A reasonable response, which I don't think was made, is that the rules
can be more rigorously defined than in ECMA-262 by testing the number
using a regular expression and varying the second argument based on the
results of that test:

parseInt(value, /^\s*0\d/.test(value) ? 8 : 0);

where value is some string. This allows for the same flexibility less
the ambiguity of step 11.

If octal is to be ignored and only decimal or hexadecimal is to be
accepted, then swap 8 for 10.

There are, of course, other approaches, including more explicit tests
using a regular expression, or getting unequivocal indication from the
user via other form controls.

[snip]

Mike
A lot seems to have happened whilst I've been absent...
Nov 30 '06 #31

P: n/a
Dr J R Stockton wrote:
But, you being a Failed FAQ writer, it ill behoves you to criticise one
who is at least trying.

Your considering only recent events, by which Richard Cornford seemingly
did not update the FAQ entries, without even slightly taking into
account the tremendous work he has done in the past, makes this "Failed"
attribute extremely ungrateful and offensive.

As an occasional reader of this list, I have been very satisfied with
his work so far, with the FAQ document itself as well as with the FAQ
notes he has created and developed, which gather some of the best
javascript articles I have read on public data sources.

His not having the time or the will to maintain it anymore will not
change this: he was not paid for what appears to be a difficult and
time-consuming task, and yet successfully managed to bring invaluable
profit to C.L.J participants.

Randy, I thank you for being the next maintainer, and wish you good luck
with this tough quest.
<QUOTE FROM="FAQ">
The majority of regular posters here do so voluntarily in their free
time. They have good days and bad days just like everyone else.
</QUOTE>

Today's one of my bad day, probably. However... while it is in a way
motivating to see how passionate people have become about the FAQ, I
feel sad to notice that this FAQ subject is kind of able to so easily
dismiss good relationships and respect in participants' discussions.
Kind regards.
Nov 30 '06 #32

P: n/a
Randy Webb wrote:
Dr J R Stockton said the following on 11/28/2006 3:01 PM:
[snip]
>Randy asserts that there are exactly three exceptions - which is
egg-on-his-face if anyone demonstrates another,

No. The entry doesn't say "The only three exceptions are.."
True, but to me (and apparently others), the word "only" merely adds
emphasis to what's otherwise a definite statement: "The three exceptions
are...". "The three" - it implies that there are no others.
It said "Three exceptions are".
It currently includes a preceding "the".

Something odd, though: you appear to argue, and I would agree, that
"Three exceptions are..." means "Here are three; there could be more".
Why doesn't that apply to my "One exception is..."? :-)

So much over a couple of words...

Mike
Nov 30 '06 #33

P: n/a
In comp.lang.javascript message
<11*********************@j72g2000cwa.googlegroups. com>, Tue, 28 Nov 2006
17:28:40, Peter Michaux <pe**********@gmail.comwrote:
>In Section 4.22

The function name "Random" is capitalized which is usually reserved for
constructor functions. Perhaps this should be lower case

The featured code in the yellow box doesn't answer the section's title
question. The actual answer is added like an after thought.
>gives a random number in the range 0..(x-1); Random(N)+1 for [1..N]

The range notation is not consistent in this sentence. I suggest the
use standard range notation: [1, N] and [1, N) or [1, N-1]
"Random" was chosen so as to be reminiscent of, but visually and
computationally distinct from, the "random" in
with (Math) X = random() ;
and to match the corresponding function in other languages.

The code shoes the recommended function, the basic one which is commonly
needed. The "actual answer" is not an afterthought; it is the
completion of the response.

One should not expect the target FAQ audience to know the "standard
range notation"; but the Subject could be changed to include "1 to N"
and the text similarly.

The argument of the function is given as "x" because it does not need to
be integer; in the text N is used, as non-integer is rare.

Query - Random(N) is often used where a return value of N would be
unacceptable. AIUI, some versions of Opera would sometimes return 1.0
from Math.random(). Does that occur often enough nowadays to justify
including the "%1" fix?

>Ajax only has one capital letter. It may be an acronym but Ajax was
also a Greek God or something.
Ajax was a Greek Hero of the Trojan Wars. Or two heroes, to be more
accurate; there was also a Lesser Ajax. For that name, the form "Ajax"
is correct in English.

But "AJAX is shorthand for Asynchronous Javascript and XML" - it is,
like OTAN, an acronym and should be capitalised. ^ So, I think, should
that "and".

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Delphi 3? Turnpike 6.05
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htmclpdmFAQ;
<URL:http://www.borland.com/newsgroups/guide.htmlnews:borland.* Guidelines
Nov 30 '06 #34

P: n/a
Michael Winter said the following on 11/30/2006 12:41 PM:
Randy Webb wrote:
>Dr J R Stockton said the following on 11/28/2006 3:01 PM:

[snip]
>>Randy asserts that there are exactly three exceptions - which is
egg-on-his-face if anyone demonstrates another,

No. The entry doesn't say "The only three exceptions are.."

True, but to me (and apparently others), the word "only" merely adds
emphasis to what's otherwise a definite statement: "The three exceptions
are...". "The three" - it implies that there are no others.
I can see that.
>It said "Three exceptions are".

It currently includes a preceding "the".
Fair enough :)
Something odd, though: you appear to argue, and I would agree, that
"Three exceptions are..." means "Here are three; there could be more".
Why doesn't that apply to my "One exception is..."? :-)
I guess it does :)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 30 '06 #35

P: n/a
Dr J R Stockton said the following on 11/30/2006 6:29 AM:
In comp.lang.javascript message
<11*********************@j72g2000cwa.googlegroups. com>, Tue, 28 Nov 2006
17:28:40, Peter Michaux <pe**********@gmail.comwrote:
>In Section 4.22

The function name "Random" is capitalized which is usually reserved for
constructor functions. Perhaps this should be lower case

The featured code in the yellow box doesn't answer the section's title
question. The actual answer is added like an after thought.
>>gives a random number in the range 0..(x-1); Random(N)+1 for [1..N]
The range notation is not consistent in this sentence. I suggest the
use standard range notation: [1, N] and [1, N) or [1, N-1]

"Random" was chosen so as to be reminiscent of, but visually and
computationally distinct from, the "random" in
with (Math) X = random() ;
and to match the corresponding function in other languages.

The code shoes the recommended function, the basic one which is commonly
needed. The "actual answer" is not an afterthought; it is the
completion of the response.

One should not expect the target FAQ audience to know the "standard
range notation"; but the Subject could be changed to include "1 to N"
and the text similarly.
Changed to this:

Question: How do I generate a random integer from 1 to N?

function Random(x) { return Math.floor(x*Math.random()) }
gives a random number in the range from 0 to x-1;
Random(N)+1 for 1 to N
The argument of the function is given as "x" because it does not need to
be integer; in the text N is used, as non-integer is rare.
Query - Random(N) is often used where a return value of N would be
unacceptable. AIUI, some versions of Opera would sometimes return 1.0
from Math.random(). Does that occur often enough nowadays to justify
including the "%1" fix?
Most Opera users use it by choice and seem to be pretty predictable
about updating it so I wouldn't think that Opera6 (IIRC it was 6) is
much of an issue anymore.
>Ajax only has one capital letter. It may be an acronym but Ajax was
also a Greek God or something.

Ajax was a Greek Hero of the Trojan Wars. Or two heroes, to be more
accurate; there was also a Lesser Ajax. For that name, the form "Ajax"
is correct in English.

But "AJAX is shorthand for Asynchronous Javascript and XML" - it is,
like OTAN, an acronym and should be capitalised. ^ So, I think, should
that "and".
Corrected to read AJAX and with the "And" capitalized. I have always
referred to it, personally, as AJAX because it is an acronym. But, most
of the references/resources I checked it against refer to it as "Ajax"
<shrug>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 30 '06 #36

P: n/a
Dr J R Stockton said the following on 11/29/2006 6:23 PM:
It is a change (in falsely-dated 9.0) from 8.1.
With regards to the date, I am not changing the date on it every time I
update it.

The date that was put on it was a tentative date for trying to get it
updated to the point where it could be moved to replace the current FAQ.
If/When it gets moved, the date will be corrected. Until then, the date
there is irrelevant, is it not?
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 30 '06 #37

P: n/a
In comp.lang.javascript message <7a********************@telcove.net>,
Thu, 30 Nov 2006 01:00:41, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/29/2006 6:51 PM:
>However, the code cited above lacks one advantage of DynWrite : it is,
wherever used, longer.
function DineRite(ID, HTML) {
document.getElementById(ID).innerHTML = HTML }
is the way to go, so that in the code one sees the job each time and
not
the mechanism.

That one is shorter but it suffers a flaw that my code dosen't.
Then explain it. Don't attempt to demonstrate superiority by obscurity.

--
(c) John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Nov 30 '06 #38

P: n/a
In comp.lang.javascript message <45**********************@news.free.fr>,
Thu, 30 Nov 2006 17:44:58, Elegie <el****@invalid.comwrote:
>Dr J R Stockton wrote:
>But, you being a Failed FAQ writer, it ill behoves you to criticise
one who is at least trying.


Your considering only recent events, by which Richard Cornford
seemingly did not update the FAQ entries, without even slightly taking
into account the tremendous work he has done in the past, makes this
"Failed" attribute extremely ungrateful and offensive.

It was intended to be so.

I don't recall how many versions he did produce, or at what intervals,
before his last one of 2005-11-05. IIRC, his final version was not
greatly different from the last version edited by Jim Ley, though he had
made some changes. His work up till then was satisfactory, but is past
history.

It is not clear whether he has been editing or adding to the Notes,
since they are undated.

But since then, in over a year, he has produced absolutely nothing, in
spite of there having been a continual flow of suggestions, of which at
least some were good. He has not even produced, AFAIK, a resignation.
That at least would have been constructive.

--
(c) John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Nov 30 '06 #39

P: n/a
In comp.lang.javascript message
<_d*****************@text.news.blueyonder.co.uk> , Thu, 30 Nov 2006
15:59:54, Michael Winter <m.******@blueyonder.co.ukwrote:
>Dr J R Stockton wrote:
>In comp.lang.javascript message <H6********************@telcove.net>,
Wed, 29 Nov 2006 00:19:38, Randy Webb <Hi************@aol.comwrote:
>>Dr J R Stockton said the following on 11/28/2006 7:43 AM:

[snip]
>>>"4.12 Why does K = parseInt('09') set K to 0?
Function parseInt(S, B) accepts two arguments, string S and base
B; the first character (leading whitespace excepted) in S which
in that position cannot be part of a base-B number terminates
number reading.
If B is not given : S with leading "0x" or "0X" is read as
Hexadecimal, else S with leading "0" is read as Octal, otherwise
S is read as Decimal. Generally, it is better to use unary + : K
= +S ."
I won't have this argument with you again. It has been had in the
past and when it was had you simply ducked around the argument.
I don't recall arguing about whether parseInt("09") gives an error.

That wasn't the argument.
Precisely. Rem acu tetigisti. The previous discussion was just about
what parseInt *returns*. The first point of this one is that the
existing Subject line of 4.12 is badly chosen, since a correct answer to
it must start by saying that parseInt('09') does not give an error, but
returns 0 or 9.

To get a good FAQ entry, one must choose a well-asked question.
Convention is that a FAQ contributor can compose a question which
reflects what the questioners ought to have asked.
If the first code executed in a page is A then an error is given,
since A is undefined. Math.random(), sometimes, in some Opera, returns
(we are told) 1.0 - that number is in error, but no error is reported.
But parseInt never gives an error AFAICS; all it can do is return a
Number which is not that hoped for or expected or needed - but which
AFAIK is always compatible with ECMA.

>It gives Number 0, as is right and proper.

No, it /may/ return zero. It may also return 9, which is correct, too.
Opera, for instance, returns the latter.
But under the Subject of the existing FAQ it probably does not return 9,
since an error is asserted by the Subject; and, under my suggested
Subject, above it certainly gives 0. I don't recall anyone asking why
it gives 9; that question is valid, but not frequent.

Nevertheless, if a FAQ description says what parseInt does, it should
certainly include both what ECMA requires or permits and what browsers
actually do.
>The argument began from (what I believe to be) the sensible conclusion
that the second, base argument should be passed to the function. Your
counterargument was that such an action prevents users from entering
hexadecimal numbers of the form 0xHH, which would otherwise receive
treatment as base-16 numbers.
I disagree with your conclusion (as a FAQ recommendation) because it is
not always valid. As a general rule for the majority of commercial
applications, it holds - with a doubt whether there are any cases where
unary plus cannot be used *and* parseInt needs an explicit base 10.

Aside: parseInt needs explaining; but unary + needs recommending.

But the FAQ should not confine itself to commercial usage; without the
technical world, there would be much less commercial world, no
javascript, and so no FAQ.
>A reasonable response, which I don't think was made, is that the rules
can be more rigorously defined than in ECMA-262 by testing the number
using a regular expression and varying the second argument based on the
results of that test:

parseInt(value, /^\s*0\d/.test(value) ? 8 : 0);

where value is some string. This allows for the same flexibility less
the ambiguity of step 11.
That may need developing to allow for signed numbers. /^\s*[-+]?0\d/
might suffice. Using (value, 8*/^\s*[-+]?0\d/.test(value) would be
cruel.
>If octal is to be ignored and only decimal or hexadecimal is to be
accepted, then swap 8 for 10.

There are, of course, other approaches, including more explicit tests
using a regular expression, or getting unequivocal indication from the
user via other form controls.
ISTM that the latter is often best; the other controls can if
appropriate allow for parseInt(S) or parseInt(S, 0) to be used with the
user taking responsibility for providing a good string. After all,
no-one in their right mind would actually provide "09" and want it to be
treated as octal Zero, terminator 9.

It's a good idea to read the newsgroup and its old FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
<URL:http://www.jibbering.com/faq/ Old RC FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 30 '06 #40

P: n/a
Dr J R Stockton said the following on 11/30/2006 3:29 PM:
In comp.lang.javascript message <7a********************@telcove.net>,
Thu, 30 Nov 2006 01:00:41, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/29/2006 6:51 PM:
>>However, the code cited above lacks one advantage of DynWrite : it is,
wherever used, longer.
function DineRite(ID, HTML) {
document.getElementById(ID).innerHTML = HTML }
is the way to go, so that in the code one sees the job each time and
not
the mechanism.

That one is shorter but it suffers a flaw that my code dosen't.

Then explain it. Don't attempt to demonstrate superiority by obscurity.

Practice what you preach.

The only difference between your code and mine is that yours is wrapped
in a function and lacks any feature detection at all. Your claim was
that my code "was longer", and it is, for the reason of feature detection.

function DineRite(ID, HTML){
if (document &&
document.getElementById &&
document.getElementById(ID) &&
document.getElementById(ID).innerHTML)
{
document.getElementById(ID).innerHTML = HTML;
}
}

If the browser doesn't support getElementById, if the element doesn't
exist, or the browser doesn't support innerHTML then your version throws
an error. That is the flaw that your code suffers from that the code I
posted doesn't suffer from.

That brings up the question of what browser doesn't support it and the
only ones I know of are IE4, NN4 and previous browsers. Which kind of
makes it a moot point but the FAQ, as well as regulars here, stresses
using feature detection.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 1 '06 #41

P: n/a
Randy Webb said the following on 11/30/2006 8:58 PM:
Dr J R Stockton said the following on 11/30/2006 3:29 PM:
>In comp.lang.javascript message <7a********************@telcove.net>,
Thu, 30 Nov 2006 01:00:41, Randy Webb <Hi************@aol.comwrote:
>>Dr J R Stockton said the following on 11/29/2006 6:51 PM:
>>>However, the code cited above lacks one advantage of DynWrite : it is,
wherever used, longer.
function DineRite(ID, HTML) {
document.getElementById(ID).innerHTML = HTML }
is the way to go, so that in the code one sees the job each time
and not
the mechanism.

That one is shorter but it suffers a flaw that my code dosen't.

Then explain it. Don't attempt to demonstrate superiority by obscurity.


Practice what you preach.

The only difference between your code and mine is that yours is wrapped
in a function and lacks any feature detection at all. Your claim was
that my code "was longer", and it is, for the reason of feature detection.

function DineRite(ID, HTML){
if (document &&
document.getElementById &&
document.getElementById(ID) &&
document.getElementById(ID).innerHTML)
{
document.getElementById(ID).innerHTML = HTML;
}
}

If the browser doesn't support getElementById, if the element doesn't
exist, or the browser doesn't support innerHTML then your version throws
an error.
That is not entirely true as non-support for innerHTML but support for
the rest won't throw an error, it simply doesn't update the page. So a
semi-proper rewording might be "If the browser doesn't support gEBI or
the element doesn't exist then an error occurs".

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 1 '06 #42

P: n/a
On Thu, 30 Nov 2006 20:58:16 -0500, Randy Webb
<Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/30/2006 3:29 PM:

If the browser doesn't support getElementById, if the element doesn't
exist, or the browser doesn't support innerHTML then your version throws
an error. That is the flaw that your code suffers from that the code I
posted doesn't suffer from.
<div id="chicken">false</div>

....

Jim.
Dec 1 '06 #43

P: n/a
VK

Randy Webb wrote:
I think that 3.2 is getting sufficiently lengthy enough that it might
benefit from being moved to a page of it's own.

Thoughts and comments are welcome.
<http://www.jibbering.com/faq/#FAQ3_2>

I see no immediate need to move links onto a separate page, but I would
suggest to group links by logical sections and place them in some
"usability order". Say Netscape 4 documentation doesn't need to be the
second link from the top, right after "check it first".

<vk... </vkmarks my comments.
Javascript FAQ site, please check first:-
<http://javascript.faqts.com>
<vk>Does it really has to be the very first resource
for someone willing to learn JavaScript? That seems
more like a resource for advanced users
doing advanced scripting. IMHO anyway.</vk>
1. Browser producers documentation

Mozilla JavaScript 1.5 reference:-
<http://developer.mozilla.org/en/docs/JavaScript>

Mozilla DOM Reference:-
<http://www.mozilla.org/docs/dom/domref>
<vk>"Online Gecko DOM Reference" is confusing
in context of "Mozilla JavaScript 1.5 reference":
as if these are two different organizations.
"Mozilla" is more recognizable for a novice,
so should be preferred over "Gecko".</vk>

Download:-
<http://www.mozilla.org/docs/dom/domref.zip>
(817Kb, HTML format)
<vk>Size and format should be indicated for all downloads.</vk>

Microsoft JScript 5.6 reference and related resources:-
<http://msdn.microsoft.com/library/en-us/script56/html/1e9b3876-3d38-4fd8-8596-1bbfe2330aa9.asp>
<vk>The title is uniformed with the Mozilla resource above</vk>
<vk>Important!
The current link doesn't work for Internet Explorer: it randomly
reports "Page not found" and stays there or "Page not found" and
then 5 sec delay redirection to the correct location. The first
one
is simply bad, the second is very confusing for a novice.
The link was updated.</vk>

Download:
<http://www.microsoft.com/downloads/details.aspx?familyid=01592C48-207D-4BE1-8A76-1C4099D7BBB9>
(2.8Mb, Microsoft Windows .chm help file)

Microsoft DOM reference:-
<http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp>
<vk>The title is uniformed with the Mozilla resource above</vk>

Opera JavaScript and DOM documentation:-
<http://www.opera.com/docs/specs/#ecmascript>
<http://www.opera.com/docs/specs/js/>

iCab InScript documentation:-
<http://www.muchsoft.com/inscript/>
<vk>Watch the corrected case for UA and script names</vk>

Safari Developer FAQ:-
<http://developer.apple.com/internet/safari/faq.html>
<vk>Added for your considerations</vk>

2. Standards and specifications

The official ECMAScript specification:-
<http://www.ecma-international.org/publications/standards/Ecma-262.htm>

Other versions of the ECMAScript specification:-
<http://www.mozilla.org/js/language/>

DOM Level 1 ECMAScript language binding
<http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html>

DOM Level 2 ECMAScript language binding
<http://www.w3.org/TR/DOM-Level-2-HTML/ecma-script-binding.html>
<vk>Both items above re-named properly, also W3C typo corrected:
the relevant language is called "ECMAScript", not "ECMA script",
it is typed properly only in the 2nd document.</vk>

3. Other ECMAScript implementations

FESI - a free implementation of ECMAScript in Java:-
<http://www.lugrin.ch/fesi/index.html>

Whitebeam Apache Module - Server Side Javascript in Apache;-
<http://www.whitebeam.org>
Digital Mars DMD Script, console and MS Active Script implementation of
ECMAScript, claimed to be faster than other implementations:-
<http://www.digitalmars.com/dscript/>

4. Developer resources:-

Source code and tutorials:-
<http://www.w3schools.com/>
<vk>"DHTML" term is obsolete, moreover say XSLT is not "DHTML"</vk>

Frequently asked questions about source code obfuscation:-
<http://jibbering.com/faq/obfuscate.html>
<vk>It is already covered in FAQ 4.1, so I see no need
to repeat the same but in more words. I could be
safely removed and referenced instead in actual posts.</vk>


Sites discussing Active Server Pages:-
<http://www.15seconds.com/>
<http://www.4guysfromrolla.com/>
<http://www.aspfaq.com/>
<vk>The majority of ASP pages
being programmed in VBScript, not JScript.
This way a generic ASP sites are irrelevant
to ECMAScript. If they contain some JScript
specific sections then link them directly.
Respectively the link should be renamed to
something like "JScript in ASP".</vk>

Sites focused on using Scripting to automate Windows:-
<http://www.windows-script.com/>
<http://cwashington.netreach.net/>
<vk>Again: VBScript or JScript scripting?
Same considerations as for the item above</vk>

Microsoft's Windows Scripting Host (WSH) Newsgroup:-
<microsoft.public.scripting.wsh>
<vk>Again: VBScript or JScript scripting?
Same considerations as for the item above</vk>

Manipulating times, dates and the lastModified date and time in
javascript:-
<http://www.merlyn.demon.co.uk/js-dates.htm>

5. Developer tools

Venkman - Mozilla Visual JS debugger:-
<http://www.mozilla.org/projects/venkman/>


Microsoft Script Debugger Download:
<http://msdn.microsoft.com/downloads/list/webdev.asp>
<vk>This link is not valid and never was. I'm not
sure how did it slip in here. Simply remove it.
It could be replaced by two new items below:</vk>

Microsoft Script Debugger:-
<http://en.wikipedia.org/wiki/Microsoft_Script_Debugger>

Microsoft Visual Studio Express (free version):-
<http://msdn.microsoft.com/vstudio/express/vwd/>

6. Legacy resources

Netscape JavaScript 1.3 reference:-
http://docs.sun.com/source/816-6408-10/contents.htm
<vk>was: "Index of Netscape 4 JavaScript docs online
(These documents are no longer available form Netscape
but are still reproduced by Sun Microsystems, Inc.)"
The title is corrected and shortened.</vk>

Index of Archived Netscape 4 JavaScript docs online and for download:-
http://devedge-temp.mozilla.org/libr...1.3/reference/
<vk>I see no download links in there (?) Otherwise it is exactly what
the
above item is. IMHO only one should stay: and I suggest this one.
As there is not enough confusion between Java and javascript: why
add more by referencing JavaScript docs from sun.com?</vk>

Archived documentation for MSIE 3.x:-
http://members.tripod.com/~housten/download/

7. Browser download links
<vk>Suggested section to add</vk>

Dec 1 '06 #44

P: n/a
Jim Ley said the following on 12/1/2006 4:35 AM:
On Thu, 30 Nov 2006 20:58:16 -0500, Randy Webb
<Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/30/2006 3:29 PM:

If the browser doesn't support getElementById, if the element doesn't
exist, or the browser doesn't support innerHTML then your version throws
an error. That is the flaw that your code suffers from that the code I
posted doesn't suffer from.

<div id="chicken">false</div>
I remember :) And that is why I replied to myself and corrected myself.

That wasn't the specific flaw that I had in mind though. If the browser
doesn't support getElementById then trying to use it results in a
visible JS error. If the element doesn't exist then trying to access
document.getElementById('incorrectID').property then it results in a JS
error.

I think what you are referring to is not knowing for sure that setting
the .innerHTML actually changes the .innerHTML of an element and any
code that uses .innerHTML is subject to that flaw :\

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 1 '06 #45

P: n/a
In comp.lang.javascript message <pt********************@telcove.net>,
Thu, 30 Nov 2006 16:59:44, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/29/2006 6:23 PM:
>It is a change (in falsely-dated 9.0) from 8.1.

With regards to the date, I am not changing the date on it every time I
update it.

The date that was put on it was a tentative date for trying to get it
updated to the point where it could be moved to replace the current FAQ.
If/When it gets moved, the date will be corrected. Until then, the date
there is irrelevant, is it not?

No. If one looks again at NEWFAQ on the Web, one wants to know whether
there are any changes from last time. For those who feel no need to
look more than once a day - non-addicts - the date of editing would
serve nicely, since most people know the current date and most
interested know roughly when they last looked at the Web copy.

Changing the number would also serve.

Technical documents, of any form, should bear the identity of the
responsible person or organisation, and an indication of their age, to
an appropriate degree of accuracy.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Dec 1 '06 #46

P: n/a
In comp.lang.javascript message <pt********************@telcove.net>,
Thu, 30 Nov 2006 16:50:36, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/30/2006 6:29 AM:
>In comp.lang.javascript message
<11*********************@j72g2000cwa.googlegroups .com>, Tue, 28 Nov 2006
17:28:40, Peter Michaux <pe**********@gmail.comwrote:
>>In Section 4.22
>Changed to this:

Question: How do I generate a random integer from 1 to N?

function Random(x) { return Math.floor(x*Math.random()) }
gives a random number in the range from 0 to x-1;
Random(N)+1 for 1 to N
Completely adequate.

I'd insert "use" after the semi-colon, on aesthetic grounds.

Actually, the result is an integer, rather than a general Number, so I'd
put "random integer".

The upper limit is really Ceil(x-1) or Ceil(x)-1.

One should never want to write Random(0) or Random(1) in code; but in an
algorithm calls with those parameters may occur (well, at least the
second case occurs) and the return value is OK.

Random does not give good results for x < 0 (example : Random(-2)
matches -Random(2)-1 EXCEPT that it gives zero once per 2^K times where
K is probably 32, 53, or 64. So in a full description I'd include
(x>=0).

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zipTimo Salmi's Turbo Pascal FAQ.
Dec 1 '06 #47

P: n/a
In article <pt********************@telcove.net>, Randy Webb
<Hi************@aol.comwrites

<snip>
>Changed to this:

Question: How do I generate a random integer from 1 to N?

function Random(x) { return Math.floor(x*Math.random()) }
gives a random number in the range from 0 to x-1;
Random(N)+1 for 1 to N
<snip>

Would you be willing to add 'inclusive', as in

gives a random number in the range from 0 to x-1 inclusive;

Then there is no doubt about the meaning.

Also, 'random number' should be 'random integer' to match the question.

John
--
John Harris
Dec 1 '06 #48

P: n/a
Dr J R Stockton said the following on 12/1/2006 5:41 AM:
In comp.lang.javascript message <pt********************@telcove.net>,
Thu, 30 Nov 2006 16:59:44, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/29/2006 6:23 PM:
>>It is a change (in falsely-dated 9.0) from 8.1.

With regards to the date, I am not changing the date on it every time
I update it.

The date that was put on it was a tentative date for trying to get it
updated to the point where it could be moved to replace the current FAQ.
If/When it gets moved, the date will be corrected. Until then, the
date there is irrelevant, is it not?


No. If one looks again at NEWFAQ on the Web, one wants to know whether
there are any changes from last time. For those who feel no need to
look more than once a day - non-addicts - the date of editing would
serve nicely, since most people know the current date and most
interested know roughly when they last looked at the Web copy.
OK, I will start changing it when I modify and upload it.
Changing the number would also serve.
Would it be better then to re-number it to 8.2 or so and when it becomes
a final draft to go live with then change it to 9.0?
Technical documents, of any form, should bear the identity of the
responsible person or organisation, and an indication of their age, to
an appropriate degree of accuracy.
Valid Point.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 1 '06 #49

P: n/a
Dr J R Stockton said the following on 12/1/2006 6:12 AM:
In comp.lang.javascript message <pt********************@telcove.net>,
Thu, 30 Nov 2006 16:50:36, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 11/30/2006 6:29 AM:
>>In comp.lang.javascript message
<11*********************@j72g2000cwa.googlegroup s.com>, Tue, 28 Nov 2006
17:28:40, Peter Michaux <pe**********@gmail.comwrote:

In Section 4.22
>Changed to this:

Question: How do I generate a random integer from 1 to N?

function Random(x) { return Math.floor(x*Math.random()) }
gives a random number in the range from 0 to x-1;
Random(N)+1 for 1 to N

Completely adequate.

I'd insert "use" after the semi-colon, on aesthetic grounds.
Added.
Actually, the result is an integer, rather than a general Number, so I'd
put "random integer".
Changed
The upper limit is really Ceil(x-1) or Ceil(x)-1.

One should never want to write Random(0) or Random(1) in code; but in an
algorithm calls with those parameters may occur (well, at least the
second case occurs) and the return value is OK.
Not sure I would agree with the return value being OK since this code:

<script type="text/javascript">
function Random(x) { return Math.floor(x*Math.random()) }

for (i=0;i<1000;i++) document.write(Random(1))
</script>

Prints out 1,000 zeros.

Yes, that is "OK" in that there are no errors but the return value is
pretty useless.
Random does not give good results for x < 0 (example : Random(-2)
matches -Random(2)-1 EXCEPT that it gives zero once per 2^K times where
K is probably 32, 53, or 64. So in a full description I'd include
(x>=0).
Since x=1 gives such useless results I added "where N>2".

Modified proposed entry:

How do I generate a random integer from 1 to N?

function Random(x) { return Math.floor(x*Math.random()) }
gives a random integer in the range from 0 to x-1 ; use
Random(N)+1 for 1 to N where N>2.

Do you have a page/anchor, or know of one, that deals with random
numbers where X<2 that I could add a link reference to the entry?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 1 '06 #50

89 Replies

This discussion thread is closed

Replies have been disabled for this discussion.