473,395 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

New FAQ Version for review

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
89 3759
John G Harris said the following on 12/1/2006 3:49 PM:
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;
Done.
Then there is no doubt about the meaning.

Also, 'random number' should be 'random integer' to match the question.
Done, JRS pointed it out also.

See my reply to John Stockton for a proposed modified entry there. The
proposed entry doesn't have inclusive in it but it is added in my local
copy to be uploaded.

--
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 #51
Randy Webb said the following on 12/1/2006 4:36 PM:
<snip>
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.

Modified to say from "0 to x-1 inclusive".

--
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 #52
VK said the following on 12/1/2006 11:42 AM:
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".
Yes, I tried making it an OL list and the file that creates the HTML
balked on it. When I have time I have to go through the process.wsf file
and find where it is balking and try to correct it. Making it an OL
would, as JRS suggested, make it easier to reference the links.

As for re-ordering them, absolutely. It would make it easier to keep the
separated and put like links together. As for what order, I will work on
that this weekend and try to get a new update posted.

--
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 #53
In comp.lang.javascript message <_M********************@telcove.net>,
Thu, 30 Nov 2006 20:58:16, Randy Webb <Hi************@aol.comwrote:
>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

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
That is the important difference. Don't confuse "way to go" with "final
solution.

It is IMPORTANT, for efficient work, that detailed code is not repeated
where it could be better put into a loop or a function. And if the
details are hidden away in a function the calling code is less
cluttered.

However long or short the meat of the section is, provided that it
exceeds about a third of a line and is used repeatedly, putting it into
a function is better. We see frequently in what is posted in the group
that the naive do not think of that.
>and lacks any feature detection at all. Your claim was that my code
"was longer", and it is, for the reason of feature detection.
No. Your document.getElementById(ID).innerHTML = HTML; is longer
than my DineRite(ID, HTML). Feature detection makes it even longer
every time that it is written - so write it once.
>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.

And yours suffers the flaw that if a naive site writer copies it (and
the FAQ is aimed at naive users), then someone reading without
getElementById will have something not working without any indication.
Remember that in general the reader does not know exactly what to
expect.

With my short version the reader will at least know that the page is
incompatible with his browser.

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

will show the writer how to give a warning.

In FAQ code, it is much better to put alerts where they might be wanted
(the FAQ reader can easily take them out) than to leave them out (the
FAQ reader may not see where they might be advisable).

If getElementById is not available, ISTM likely to be better to detect
it at the start of the page, and plan subsequent operation accordingly,
avoiding the circumstances leading to the DineRite call.

Feature detection is easy if it is a question of whether a method
exists, easy enough if it is a question of whether a method works
correctly AND one knows how it fails, and not at all easy (until one
knows how) for such as whether RegExp look-ahead works. I hope that the
relevant Notes section goes far enough.

--
(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.
Dec 1 '06 #54
VK

Dr J R Stockton wrote:
No. Your document.getElementById(ID).innerHTML = HTML; is longer
than my DineRite(ID, HTML). Feature detection makes it even longer
every time that it is written - so write it once.
May ask what browsers these "innerHTML support checks" are targeted to?
By the intensity of the discussion side readers may decide that this is
some crucial problem of the modern web-development :-): while this
problem is not practically relevant for several years already. If there
is a known web browser without innerHTML support produced over the last
say three years I'd like to know it.

If the aim is to cover NN3/IE3 as well (so excluding if(property in
object) boolean check) it could be:

<body onload="
for (var p in document.body) {
if (p == 'innerHTML') {
alert('has innerHTML');
}
}
">

But again: for what *current* purpose? And if getElementById and
innerHTML can be missing, why a bunch of other things are presumed as
"given no matter what"? Like Array constructor, Image, src attribute
support for script tag etc?

Dec 2 '06 #55
Dr J R Stockton said the following on 12/1/2006 4:32 PM:

<snip>
Feature detection is easy if it is a question of whether a method
exists, easy enough if it is a question of whether a method works
correctly AND one knows how it fails, and not at all easy (until one
knows how) for such as whether RegExp look-ahead works.
Feature detection is "easy enough"? OK, I want to know if createTextNode
works correctly in the browser. I know, quite well, how it fails in one
very widely used browser (IE). Yet, there is no feature detection test
to find out if it works correctly or not even though I know exactly how
it's going to fail (fatal error to the script). See the thread from the
last two days entitled "createTextNode and IE7" that was started by me
and you can see the issue. So no, feature detection is not always "easy
enough".

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

Randy Webb wrote:
Feature detection is "easy enough"? OK, I want to know if createTextNode
works correctly in the browser. I know, quite well, how it fails in one
very widely used browser (IE). Yet, there is no feature detection test
to find out if it works correctly or not even though I know exactly how
it's going to fail (fatal error to the script).
Purely in-script feature detection driven code is not possible in some
or many circumstances. That could be always possible only if all UA
producers either 1) don't implement a feature at all or 2) do implement
it uniformely strictly by publically available specs. Every time the
2nd happens I'm getting all nervious: because it's too good to be true
and usually means some especially big hidden sh** to explode :-) Lucky
it happens on expremely rare basis :-)
Is it bad? It *is*. Can we do something besides carefully studying each
UA of our interests? Not too much.

See also my recent discussion over SVG at
<http://groups.google.com/group/mozilla.dev.tech.svg/browse_frm/thread/92f3c6f392886f26>

Dec 2 '06 #57
VK said the following on 12/1/2006 8:02 PM:
Dr J R Stockton wrote:
>No. Your document.getElementById(ID).innerHTML = HTML; is longer
than my DineRite(ID, HTML). Feature detection makes it even longer
every time that it is written - so write it once.

May ask what browsers these "innerHTML support checks" are targeted to?
Any browser that doesn't support innerHTML <g>

The part of the post he quoted I was referring to the body of the
function of DynWrite and John, in his typically pedantic childish way,
chose to pedant that I hadn't wrapped it in a function call. Most of
that conversation was based on a philosophical issue of feature
detection but JRS totally missed it.

If DynWrite gets changed, it will be, almost verbatim:

function DynWrite(elemID,elemContent){
document.getElementById(elemID).innerHTML = elemContent;
}

Unless someone has a viable reason why it would be faulty in a modern
context.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 2 '06 #58
VK said the following on 12/1/2006 8:17 PM:
Randy Webb wrote:
>Feature detection is "easy enough"? OK, I want to know if createTextNode
works correctly in the browser. I know, quite well, how it fails in one
very widely used browser (IE). Yet, there is no feature detection test
to find out if it works correctly or not even though I know exactly how
it's going to fail (fatal error to the script).

Purely in-script feature detection driven code is not possible in some
or many circumstances.
Don't let John know that, he said it was "easy enough" and I know,
firsthand, better than that.
That could be always possible only if all UA producers either 1)
don't implement a feature at all or 2) do implement it uniformely
strictly by publically available specs.
Or 3) implements it but barely and not in accordance with the specs.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 2 '06 #59
Dr J R Stockton wrote:

[snip]
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.
Agreed. Perhaps "Why doesn't parseInt('09') return what I expect?" would
be a better question.

[snip]
I don't recall anyone asking why it gives 9; that question is valid,
but not frequent.
Most people that encounter the issue have probably only tested in an
environment that chooses octal for leading zeros. To omit the return
value of 9 might suggest that such a value is in error.
Nevertheless, if a FAQ description says what parseInt does, it should
certainly include both what ECMA requires or permits and what browsers
actually do.
An edit of the current entry:

The parseInt function decides what base the number is by
looking at the number. It assumes that any number beginning
with '0x' or '0X' is hexadecimal, but it has a choice with a
leading zero: the number can either be octal or decimal.
Assuming octal, the string '09' will be converted to 0 (octal
digits are 0-7); assuming decimal, '09' will be converted to 9
(the leading zero is ignored).
To force use of a particular radix, add a second parameter:
parseInt("09",10)

The Notes article would be a better location for more detail, if desired.

[MLW:]
>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.
Recommendations can be ignored when there is sufficient reason. They are
not requirements and there's no need to abandon judgement; the eval
function is evil, but not always.
As a general rule for the majority of commercial applications, it
holds
Which is why it's a good general recommendation. Someone with special
needs should have the sense to overlook it when they know better,
especially if the rationale for the recommendation is clear.
- with a doubt whether there are any cases where unary plus cannot be
used *and* parseInt needs an explicit base 10.
The radix need not be 10. For example, colour codes (#rrggbb) can begin
with a zero, but should be interpreted as hexadecimal. Using unary plus
would evaluate to NaN.

[snip]

[MLW:]
> parseInt(value, /^\s*0\d/.test(value) ? 8 : 0);
[snip]
That may need developing to allow for signed numbers. /^\s*[-+]?0\d/
might suffice.
Quite. Sorry.

[snip]

Mike
Dec 2 '06 #60
In comp.lang.javascript message <c8********************@telcove.net>,
Fri, 1 Dec 2006 16:24:06, Randy Webb <Hi************@aol.comwrote:
>
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?
Since it was said that the First Complete RW Version would be released
as 9.0 on 2006-12-01, I think I have to answer a definite Don't Know.

On second thoughts, no. The numbering sequence must increase
monotonically; consecutive releases of the same number are appropriate
only where the change is truly cosmetic (e.g. more tasteful shades of
similar colours done in the CSS).

But, starting from where I think we may be, I suggest using 10.0 for the
number of the first release for which you are fully responsible, with a
target date of Before 2007 and an actual date of whatever it is.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Dec 2 '06 #61
In comp.lang.javascript message <hY********************@telcove.net>,
Fri, 1 Dec 2006 16:36:29, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 12/1/2006 6:12 AM:
> 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.
If I were rewriting that, I think I'd omit the reference to Random(0).
One can choose an element from a set of 1 or more elements, but not from
an empty set.
>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.
That's right. Each of those zeroes could have been chosen, at
equi-probable random, from a set of digits holding a single zero.
Remember that N factorial is generally considered as the product of all
integers from 1 to N, but 1!=1 then involves no multiplication and 0!=1
involves no integers. A broader definition is that (for N>=0) N! is "1
times all the integers from 1 or 2 to N in turn".
>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".
NO. In an algorithm similar to shuffling, where a sequence of N is
used, it may be desirable to include N=1 rather than to add code to
exclude it. There, "similar to" does not include "the same as".

The limits of validity given in a description of an algorithm should
include all cases in which it is correct, without regard to any
judgement of utility; otherwise, a reader may waste time/effort by
assuming that it is not valid outside the stated limits.

There is no need for " 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?
Offhand, no. In the cases I've looked at today, the coding has been
able to avoid using Random(1) without extra code.
It's always wise to allow extreme cases as a limit of non-extreme cases.

In Algol, IIRC, arrays are dynamically sized when the block containing
the declaration is executed. Ignoring syntax errors,

procedure X(N) ;
var A : array [1:N] ; J : integer ;
begin for J = 1 step 1 to N do A[J] := 0 ; end;

will work for integer N 0; but the declaration will fail for N=0,
though the loop would execute perfectly, zero times. A corresponding
Javascript can handle an array of no elements.

--
(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
Dec 2 '06 #62
Michael Winter said the following on 12/2/2006 12:30 PM:

<snip>
An edit of the current entry:

The parseInt function decides what base the number is by
looking at the number. It assumes that any number beginning
with '0x' or '0X' is hexadecimal, but it has a choice with a
leading zero: the number can either be octal or decimal.
Assuming octal, the string '09' will be converted to 0 (octal
digits are 0-7); assuming decimal, '09' will be converted to 9
(the leading zero is ignored).
To force use of a particular radix, add a second parameter:
parseInt("09",10)

The Notes article would be a better location for more detail, if desired.
Changed.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 2 '06 #63
In comp.lang.javascript message <_6********************@telcove.net>,
Fri, 1 Dec 2006 20:18:20, Randy Webb <Hi************@aol.comwrote:
>The part of the post he quoted I was referring to the body of the
function of DynWrite and John, in his typically pedantic childish way,
chose to pedant that I hadn't wrapped it in a function call. Most of
that conversation was based on a philosophical issue of feature
detection but JRS totally missed it.
No; at that time I had nothing to add about feature detection, so I
added nothing about it. Instead, I addressed what you had omitted.

Proper modularisation of code is IMPORTANT, and a FAQ should never set a
bad example.
>If DynWrite gets changed, it will be, almost verbatim:

function DynWrite(elemID,elemContent){
document.getElementById(elemID).innerHTML = elemContent;
}
There'd be something to be said for changing the function identifier
slightly, to make it easier to refer to both the new and the old.

IMHO, where space permits, every token-separator-comma should be
followed by whitespace; and every statement-terminator-semicolon & many
for-parentheses-semicolons should be surrounded by whitespace. The
Javascript engine will not care, but the script will be more legible.
--
(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.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Dec 2 '06 #64
In comp.lang.javascript message
<7L******************@text.news.blueyonder.co.uk >, Sat, 2 Dec 2006
17:30:43, Michael Winter <m.******@blueyonder.co.ukwrote:
>Dr J R Stockton wrote:
>An edit of the current entry:

The parseInt function decides what base the number is by
looking at the number. It assumes that any number beginning
with '0x' or '0X' is hexadecimal, but it has a choice with a
leading zero: the number can either be octal or decimal.
Good, but maybe slightly improvable without significant expansion. The
function has no choice; the choice was made by its authors. Maybe :

"... hexadecimal; otherwise, a string with a leading zero may be read as
either octal or decimal."

The input to parseInt should be referred to as a string or String; it is
not a number.

In fact, as "number" is used to mean "decimal digit" and "integer" and
"real number", it's probably best to use it as little as possible (and
to save "Number" for the meaning in Javascript).

Assuming octal, the string '09' will be converted to 0 (octal
digits are 0-7); assuming decimal, '09' will be converted to 9
(the leading zero is ignored).
To force use of a particular radix, add a second parameter:
parseInt("09",10)

The Notes article would be a better location for more detail, if desired.

>As a general rule for the majority of commercial applications, it
holds

Which is why it's a good general recommendation. Someone with special
needs should have the sense to overlook it when they know better,
especially if the rationale for the recommendation is clear.
That is why it's better to have, instead of "should be passed", "should
(usually/normally/generally) be passed".

>- with a doubt whether there are any cases where unary plus cannot be
used *and* parseInt needs an explicit base 10.

The radix need not be 10. For example, colour codes (#rrggbb) can begin
with a zero, but should be interpreted as hexadecimal. Using unary plus
would evaluate to NaN.
Agreed; but note the *and*. Unary + can never be used if parseInt would
need an explicit base other than 10. In that case unary + cannot be
used but parseInt needs an explicit base 16.

But Hue = parseInt(ColourCode.replace(/#/, "0X")) // *could* be used
Hue = parseInt(ColourCode.substr(1), 16) // shorter

Reading a ColourCode #abc to decimal can be done by
Hue = parseInt(ColourCode.replace(/#(\w)(\w)(\w)/, "0X$1$1$2$2$3$3"))

FAQ 8.2 - 2006-12-01 - 4.12 omits the useful point that any invalid
character terminates the number (which is why parseInt is useful when
reading properties given as a string matching /^\d+px$/).

If "To force use of base 10 add a second parameter parseInt("09",10)"
were changed to "To force use of a particular base, add a second
parameter parseInt("09", base)". That's only a little longer, answers
the case of base 10, and generalises it.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Dec 2 '06 #65
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/>
Re "comp.lang.javascript FAQ - 8.2 - 2006-12-01", collected at about
2006-12-02 20:15+-15 GMT.

Ugh!

The FAQ is fundamentally a plain-text document.

Contrary to both good manners and Disability legislation, you have
chosen to present it using YOUR choice of font face and size, whereas my
browser default is set to what suits me best. BTW, the Public Library
browsers default to much the same as mine.

You foist on me a SANS-SERIF font of REDUCED size.

I grant that it's often said that sans-serif is more legible on computer
screens; but, on a reasonably modern CRT screen (1998-2004, then
2004-date) I find that not to be so. It is MY computer; and in plain
running text you should not mess with MY fonts.

With my normal window width, 640 px - half-screen, there are too many
words per line for comfortable reading (consequence of both font face
and size). However, because the dirty pink code boxes are in Courier
(you correctly set monospace) and have whitespace on their left, some of
them extend to the right of the viewport.

The longest line in the pink box in 4.26 brings the right edge of the
box in alignment with the right margin of the text, near enough, with my
preferred viewport width. If others see similarly, I suggest that you
keep code lines below about 63 characters, where practical. (With
smaller body padding, I get 69 characters OK on my pages).

W3's HTML validator sneers : "This Page Is Tentatively Valid HTML 4.01
Transitional" and "No Character Encoding Found! Falling back to UTF-8."
Jim may be able to fix that at the server, or you in the page. Otherwise
it's happy.

W3's CSS validator claimed one error; but I don't see that its message
matches your CSS. It warns about specifying color without specifying
background-color; but you do seem to have set global background white.

AFAICS, the only useful part of the CSS is that which colours and
borders the boxes. The index should use <linot <H5and is the only
other part that looks wrong without CSS.
--
(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.
Why does NASA JSC think Dunfermline is in England?
It's learned recently that Gibraltar is not.

Dec 2 '06 #66
In comp.lang.javascript message <g8********************@telcove.net>,
Fri, 1 Dec 2006 20:04:11, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 12/1/2006 4:32 PM:

<snip>
>Feature detection is easy if it is a question of whether a method
exists, easy enough if it is a question of whether a method works
correctly AND one knows how it fails, and not at all easy (until one
knows how) for such as whether RegExp look-ahead works.

Feature detection is "easy enough"? OK, I want to know if
createTextNode works correctly in the browser. I know, quite well, how
it fails in one very widely used browser (IE). Yet, there is no feature
detection test to find out if it works correctly or not even though I
know exactly how it's going to fail (fatal error to the script). See
the thread from the last two days entitled "createTextNode and IE7"
that was started by me and you can see the issue. So no, feature
detection is not always "easy enough".

That confirms once more that a FAQ writer really does need to be able to
read English. Thomas would not have doubted.

You have responded to the first four words without considering the
influence of the following "if". The sentence refers to three cases,
indicated by "if ...", "if ...", and "for ...". It does not imply that
only three cases are possible.


In IE4, the code testRe = new RegExp("a??") was, I think, a
fatal script error. But if window.onerror had been set to a function
just returning true, then the code was a no-op. Thus *that* error can,
in IE4, be caught and so detected.

It was implied that one can do similarly with "all" browsers. Perhaps
one can do similarly for "createTextNode ... (fatal error to the
script)"?

For that technique, search the javascript newsgroups, for some while
back, for "window.onerror" (AFAIR, it occurs infrequently) or see
<URL:http://www.merlyn.demon.co.uk/js-valid.htm#RFT>.
The singular of "criteria" is "criterion".

--
(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.
Dec 2 '06 #67
On Sat, 2 Dec 2006 23:46:43 +0000, Dr J R Stockton
<re*******@merlyn.demon.co.ukwrote:
>W3's HTML validator sneers : "This Page Is Tentatively Valid HTML 4.01
Transitional" and "No Character Encoding Found! Falling back to UTF-8."
Jim may be able to fix that at the server, or you in the page. Otherwise
it's happy.
This is 'cos it's in newfaq, once index.html was in faq/ it would've
just magically worked.
>W3's CSS validator claimed one error; but I don't see that its message
matches your CSS. It warns about specifying color without specifying
background-color; but you do seem to have set global background white.
CSS "validator" rightly believes that the background colour needs to
be set anywhere the foreground is set (in case a user stylesheet
overrides the background of that element.

It's not a realistic worry though, indeed almost certainly bogus.

I agree about the 90% as default size btw.

Jim.
Dec 3 '06 #68
Jim Ley said the following on 12/3/2006 5:12 AM:
On Sat, 2 Dec 2006 23:46:43 +0000, Dr J R Stockton
<re*******@merlyn.demon.co.ukwrote:
>W3's HTML validator sneers : "This Page Is Tentatively Valid HTML 4.01
Transitional" and "No Character Encoding Found! Falling back to UTF-8."
Jim may be able to fix that at the server, or you in the page. Otherwise
it's happy.

This is 'cos it's in newfaq, once index.html was in faq/ it would've
just magically worked.
>W3's CSS validator claimed one error; but I don't see that its message
matches your CSS. It warns about specifying color without specifying
background-color; but you do seem to have set global background white.

CSS "validator" rightly believes that the background colour needs to
be set anywhere the foreground is set (in case a user stylesheet
overrides the background of that element.

It's not a realistic worry though, indeed almost certainly bogus.

I agree about the 90% as default size btw.
The entire .css file there is one that RobG did that I put up and forgot
to post the change to get feedback on it. It is now back to where it
started as far as CSS is concerned.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 3 '06 #69
Dr J R Stockton wrote:
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/>

Re "comp.lang.javascript FAQ - 8.2 - 2006-12-01", collected at about
2006-12-02 20:15+-15 GMT.

Ugh!
Pretty much what I think every time I visit the current FAQ.
The FAQ is fundamentally a plain-text document.
And it remains so. The different appearance, other than sections of
lists that were changed to ul and li elements, was achieved with small
modifications to the existing CSS.
>
Contrary to both good manners and Disability legislation, you have
chosen to present it using YOUR choice of font face and size, whereas my
browser default is set to what suits me best. BTW, the Public Library
browsers default to much the same as mine.
Don't blame Randy, it was my suggestion. My intention was to give the
FAQ a more contemporary appearance, one that does not look like it came
from 1995.

The choice of sans-serif font is in keeping with the vast majority of
web sites. If you don't like sans-serif fonts, by all means make your
position known but to claim specifying such in a CSS file is "bad
manners" is absurd. It is no more bad manners than the default setting
of browsers that "enforce" a serif font.

The claim that the suggestion of a sans-serif font in a CSS file is
contrary to legislation is news to me - please explain.
>
You foist on me a SANS-SERIF font of REDUCED size.
It is also common to reduce the size of the default font, many sites
set 80% or even 75%. Users are used to seeing fonts of that size and
often set their default font expecting a reduced size in the page (the
default font for Mozilla browsers is 16pt, when most printed fonts are
10 to 12pt). I chose 90% as a happy medium - fonts will still present
larger than in the vast majority of web pages.

What do others think?
I grant that it's often said that sans-serif is more legible on computer
screens; but, on a reasonably modern CRT screen (1998-2004, then
2004-date) I find that not to be so. It is MY computer; and in plain
running text you should not mess with MY fonts.
OK, so you vote against sans-serif fonts.

Note that you are free to use whatever font you like through your
default CSS file, you also have the ability to set a minimum font size.
>
With my normal window width, 640 px - half-screen, there are too many
words per line for comfortable reading (consequence of both font face
and size).
I think only a very few users are surfing the web with a window set to
320px. Are you seriously suggesting the FAQ be optimised for that?
However, because the dirty pink code boxes are in Courier
(you correctly set monospace) and have whitespace on their left, some of
them extend to the right of the viewport.
The "dirty pink" is a compromise. The original yellow is
uncomfortable, I was looking for something easier to look at. The
styles were tested on a number of computers, screens, browsers and
operating systems, the differences in appearance were dramatic - what
looks a gaudy puce on one screen is a bland maroon on another.

Please suggest alternative colours.
>
The longest line in the pink box in 4.26 brings the right edge of the
box in alignment with the right margin of the text, near enough, with my
preferred viewport width. If others see similarly, I suggest that you
keep code lines below about 63 characters, where practical. (With
smaller body padding, I get 69 characters OK on my pages).
4.37 has a longer line, your (apparently preferred) larger fonts will
exacerbate the situation. It is a convention to indent blocks of
quoted or special text (such as code examples) and therefore it is
appropriate to do so in the FAQ. The overrun is a consequence of your
narrow window width; I think it is unreasonable to expect the FAQ to be
tailored to suit that at the expense of a more conventional layout.
--
Rob

Dec 3 '06 #70
In article <HD**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites

<snip>
>But since then, in over a year, he has produced absolutely nothing,
<snip>

Isn't it time that the mistakes in js-other concerning identifiers and
semicolons were corrected ?

John
--
John Harris
Dec 3 '06 #71
RobG said the following on 12/3/2006 8:22 AM:
Dr J R Stockton wrote:
>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/>
Re "comp.lang.javascript FAQ - 8.2 - 2006-12-01", collected at about
2006-12-02 20:15+-15 GMT.

Ugh!

Pretty much what I think every time I visit the current FAQ.
>The FAQ is fundamentally a plain-text document.

And it remains so. The different appearance, other than sections of
lists that were changed to ul and li elements, was achieved with small
modifications to the existing CSS.
What was being seen was your CSS with the current FAQ layout. I know you
changed some of the layout but I can't do that - for now - with the way
the FAQ is generated. It is coded in an .xml file
(http://jibbering.com/faq/newfaq/index.sml) which is then processed by
http://jibbering.com/faq/newfaq/process.wsf) which creates the HTML file
on the fly. The XML file is so that the daily/weekly postings of the FAQ
and snippets could be easily done in text by reading the XML file. To
changes the layout means changing the process.wsf file to create it that
way. I tried making 3.2 an LI and it didn't work. I have to figure out
where a case: "LI" goes in the process.wsf file to create the lists out
of the links (or anywhere else).

Meaning, for now, you are stuck with the HTML itself until I can change
it. You can only modify what is there now with different definitions.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 3 '06 #72
In comp.lang.javascript message
<11**********************@80g2000cwy.googlegroups. com>, Sun, 3 Dec 2006
05:22:24, RobG <rg***@iinet.net.auwrote:
>Dr J R Stockton wrote:
>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/>

Re "comp.lang.javascript FAQ - 8.2 - 2006-12-01", collected at about
2006-12-02 20:15+-15 GMT.

Ugh!

Pretty much what I think every time I visit the current FAQ.
>The FAQ is fundamentally a plain-text document.

And it remains so.
That's implied by "is".
The different appearance, other than sections of
lists that were changed to ul and li elements, was achieved with small
modifications to the existing CSS.
The FAQ as seen, to all who have not overridden what it sets, is the
result of both the HTML and the CSS that are served from jibbering. The
history is unimportant, except where it shows that a change is a
mistake.

>Contrary to both good manners and Disability legislation, you have
chosen to present it using YOUR choice of font face and size, whereas my
browser default is set to what suits me best. BTW, the Public Library
browsers default to much the same as mine.

Don't blame Randy, it was my suggestion. My intention was to give the
FAQ a more contemporary appearance, one that does not look like it came
from 1995.
Randy is responsible for the FAQ, and that responsibility includes
accepting good ideas and rejecting bad ones.
<URL:http://www.merlyn.demon.co.uk/quotings.htm#Alfonso>

>The choice of sans-serif font is in keeping with the vast majority of
web sites.
One should do what is right, not just follow the fashion set by others.
If you don't like sans-serif fonts, by all means make your
position known but to claim specifying such in a CSS file is "bad
manners" is absurd. It is no more bad manners than the default setting
of browsers that "enforce" a serif font.
A browser MUST have a default font, if it is to work "out of the box". A
Web page and/or CSS file do not need to change that setting.
>The claim that the suggestion of a sans-serif font in a CSS file is
contrary to legislation is news to me - please explain.
Enforcing a setting for ordinary text other than that preferred by the
user is contrary certainly to the spirit of disability discrimination
legislation. Granted the legislation may not actually apply - but
should one ignore the visually disabled just because the law applies
only to other sites or to other countries?

>OK, so you vote against sans-serif fonts.
No: against overriding my settings.
>Note that you are free to use whatever font you like through your
default CSS file, you also have the ability to set a minimum font size.
At many client sites, the individual users cannot personalise
preferences. They should not need to do so.

And I don't want to make a CSS file that will improve what I see for the
FAQ page and thereby alter what I see on my own pages or degrade what I
see on other pages - often, I have several pages from different sources
open at once, for reference.
>With my normal window width, 640 px - half-screen, there are too many
words per line for comfortable reading (consequence of both font face
and size).

I think only a very few users are surfing the web with a window set to
320px. Are you seriously suggesting the FAQ be optimised for that?
No. 640 px is half screen. The screen is 1280 * 1024 and my normal
window width is 640 wide * 85% high (just changed from 90%). Most sites
I view are satisfactory at that (especially commercial ones where that
width cuts off half of the advertising).
>However, because the dirty pink code boxes are in Courier
(you correctly set monospace) and have whitespace on their left, some of
them extend to the right of the viewport.

The "dirty pink" is a compromise. The original yellow is
uncomfortable, I was looking for something easier to look at. The
styles were tested on a number of computers, screens, browsers and
operating systems, the differences in appearance were dramatic - what
looks a gaudy puce on one screen is a bland maroon on another.

Please suggest alternative colours.
I was happy enough with the previous colours. ISTM that one should
avoid, for routine purposes, colours near the edge of the visual
spectrum - or at least putting together colours at opposite ends of the
spectrum. But the "dirty pink" was a description, not a condemnation.
>The longest line in the pink box in 4.26 brings the right edge of the
box in alignment with the right margin of the text, near enough, with my
preferred viewport width. If others see similarly, I suggest that you
keep code lines below about 63 characters, where practical. (With
smaller body padding, I get 69 characters OK on my pages).

4.37 has a longer line, your (apparently preferred) larger fonts will
exacerbate the situation.
I chose to refer to 4.26 because its longest line was just satisfactory
here; others are manifestly longer.

My font-size complaint referred to the proportional font. Even in the
FAQ as it is, I think I'd prefer code blocks to use a slightly narrower
(but not shorter) font.

Browser defaults IMHO should enable code lines of 72 characters and text
lines of about 12 words to occupy about the same width. For that, my
IE4 was fine; but in my IE6 it is necessary to use
pre { font-size: smaller }
It is a convention to indent blocks of
quoted or special text (such as code examples) and therefore it is
appropriate to do so in the FAQ.
Code examples are not indented in the FAQ, except by about 1 em at the
edge of the boxes and for structure; the code boxes more-or-less align
on the left with the ordinary paragraphs.
The overrun is a consequence of your
narrow window width; I think it is unreasonable to expect the FAQ to be
tailored to suit that at the expense of a more conventional layout.
But there is no need to have such wide body padding - and no need to
indent paragraphs more than minor headers more than major headers.

If I increase the window width, then (a) I can no longer see all of the
code that I'm working on & reading the FAQ for (my normal editor window
is about 620 px wide); and (b) because the text of the paragraphs is 90%
and the sans-serif font has narrow characters, there are too many words
on the line for comfortable reading.

Section 2.3 (plain text only) is now most readable with my window
reduced to 80% width, which reduces the text lines by a larger factor.
That changes characters/line by about as much as two Ctrl-Mousewheel
steps.
IMHO, the FAQ should be submitted to
news:comp.infosystems.www.authoring.html and maybe
news:comp.infosystems.www.authoring.stylesheets for discussion as a
document.

--
(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.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Dec 3 '06 #73
In comp.lang.javascript message
<RJ**************@jgharris.demon.co.uk.nospam.inva lid>, Sun, 3 Dec 2006
13:42:20, John G Harris <jo**@nospam.demon.co.ukwrote:
>In article <HD**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites

<snip>
>>But since then, in over a year, he has produced absolutely nothing,
<snip>

Isn't it time that the mistakes in js-other concerning identifiers and
semicolons were corrected ?
Perhaps. But first you have to tell me what they, in your opinion, are,
and I have to agree with you or at least believe you.

--
(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.
Dec 3 '06 #74
Dr J R Stockton said the following on 12/2/2006 4:45 PM:
In comp.lang.javascript message <g8********************@telcove.net>,
Fri, 1 Dec 2006 20:04:11, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 12/1/2006 4:32 PM:

<snip>
>>Feature detection is easy if it is a question of whether a method
exists, easy enough if it is a question of whether a method works
correctly AND one knows how it fails, and not at all easy (until one
knows how) for such as whether RegExp look-ahead works.
Feature detection is "easy enough"? OK, I want to know if
createTextNode works correctly in the browser. I know, quite well, how
it fails in one very widely used browser (IE). Yet, there is no feature
detection test to find out if it works correctly or not even though I
know exactly how it's going to fail (fatal error to the script). See
the thread from the last two days entitled "createTextNode and IE7"
that was started by me and you can see the issue. So no, feature
detection is not always "easy enough".


That confirms once more that a FAQ writer really does need to be able to
read English.

I don't have a problem reading, writing, and/or typing English. It is
you who needs to learn to comprehend what you yourself write.
Thomas would not have doubted.
GFY
You have responded to the first four words without considering the
influence of the following "if".
You are making an ignorant assumption, but that is normal for you.
The sentence refers to three cases, indicated by "if ...", "if ...",
and "for ...". It does not imply that only three cases are possible.
I didn't say that it did say/imply anything. I said it was a false
statement and then gave you a scenario to prove me wrong. You have
failed to do that yet and until you do, your statement is still false.
And no amount of dodging the issue will change that.
In IE4, the code testRe = new RegExp("a??") was, I think, a
fatal script error. But if window.onerror had been set to a function
just returning true, then the code was a no-op. Thus *that* error can,
in IE4, be caught and so detected.
So you suggest I kill all error reporting in a page via a library type
function simply to pacify your desire to be right?
It was implied that one can do similarly with "all" browsers. Perhaps
one can do similarly for "createTextNode ... (fatal error to the
script)"?
Probably. But in a library type function the ability to hijack
window.onerror isn't an appealing solution. I would prefer an approach
that uses pure feature detection to detect it. I think my best solution
though is to create a variable, set it to false, and then in an IE
conditional set it to true. That doesn't feature detect for what I want
but it gets close enough as the only browser that I know of that doesn't
use createTextNode properly is IE.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 4 '06 #75
Dr J R Stockton wrote:
In comp.lang.javascript message
<11**********************@80g2000cwy.googlegroups. com>, Sun, 3 Dec 2006
05:22:24, RobG <rg***@iinet.net.auwrote:
[...]
Don't blame Randy, it was my suggestion. My intention was to give the
FAQ a more contemporary appearance, one that does not look like it came
from 1995.

Randy is responsible for the FAQ, and that responsibility includes
accepting good ideas and rejecting bad ones.
The intention was to put it up and let people comment, I guess you've
had your say.
>
The choice of sans-serif font is in keeping with the vast majority of
web sites.

One should do what is right, not just follow the fashion set by others.
As you noted, there is a good body of evidence that sans-serif fonts
are easier to read on computer screens for most web users, disabled or
not. I believe that's the reason that the vast majority of web sites
use them. The transition to sans-serif fonts has been slow and
deliberate over a number of years, I don't think it has been done
purely for the sake of fashion.

[...]
The claim that the suggestion of a sans-serif font in a CSS file is
contrary to legislation is news to me - please explain.

Enforcing a setting for ordinary text other than that preferred by the
user is contrary certainly to the spirit of disability discrimination
legislation.
There is no such enforcement, CSS is but a suggestion. If the
intention is to make the page more accessible and easier to read using
CSS (which is specifically designed to be able to be over-ridden by
those who wish to do so for whatever reason), how is that contrary to
the spirit of disability legislation? I think you are exaggerating the
issue.

[...]
IMHO, the FAQ should be submitted to
news:comp.infosystems.www.authoring.html and maybe
news:comp.infosystems.www.authoring.stylesheets for discussion as a
document.
A good suggestion, however I'd prefer if some of the more knowledgeable
regulars here would pass their eye over it first. There are some ciwah
and ciwas lurkers here who may like to comment once the new page is
ready.
--
Rob

Dec 4 '06 #76
Dr J R Stockton said the following on 12/3/2006 5:52 PM:

<snip>
IMHO, the FAQ should be submitted to
news:comp.infosystems.www.authoring.html and maybe
news:comp.infosystems.www.authoring.stylesheets for discussion as a
document.
There is nothing stopping you from posting to ciwah or ciwas and
discussing the FAQ "as a document". So feel free to do so.

As for me doing it, don't plan on it.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 4 '06 #77
RobG said the following on 12/4/2006 9:10 AM:
Dr J R Stockton wrote:
>In comp.lang.javascript message
<11**********************@80g2000cwy.googlegroups .com>, Sun, 3 Dec 2006
05:22:24, RobG <rg***@iinet.net.auwrote:
[...]
>>Don't blame Randy, it was my suggestion. My intention was to give the
FAQ a more contemporary appearance, one that does not look like it came
from 1995.

Randy is responsible for the FAQ, and that responsibility includes
accepting good ideas and rejecting bad ones.

The intention was to put it up and let people comment, I guess you've
had your say.
And it has been duly noted.
[...]
>IMHO, the FAQ should be submitted to
news:comp.infosystems.www.authoring.html and maybe
news:comp.infosystems.www.authoring.stylesheets for discussion as a
document.

A good suggestion, however I'd prefer if some of the more knowledgeable
regulars here would pass their eye over it first. There are some ciwah
and ciwas lurkers here who may like to comment once the new page is
ready.
If it were a static HTML document then it is simple to modify part of it
be some other element. Take 3.2, if it is a static document then you can
simple re-code it to be an Ordered List and everything is fine. Changing
it under the current system isn't so trivial though. From my experience
the conversations in ciwah and ciwas tend to follow the same pattern as
clj where it isn't a constructive conversation but it becomes a
philosophical debate for the ages.

FWIW, 10.0 will probably be a static HTML file.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 4 '06 #78
In comp.lang.javascript message <qe********************@telcove.net>,
Mon, 4 Dec 2006 03:22:02, Randy Webb <Hi************@aol.comwrote:
>Dr J R Stockton said the following on 12/2/2006 4:45 PM:
>In IE4, the code testRe = new RegExp("a??") was, I think, a
fatal script error. But if window.onerror had been set to a function
just returning true, then the code was a no-op. Thus *that* error can,
in IE4, be caught and so detected.

So you suggest I kill all error reporting in a page via a library type
function simply to pacify your desire to be right?
No. Just all error reporting from *immediately* before the test
statement to *immediately* after it.

The article of mine which you partly quoted ends with "For that
technique, search the javascript newsgroups, for some while back, for
"window.onerror" (AFAIR, it occurs infrequently) or see
<URL:http://www.merlyn.demon.co.uk/js-valid.htm#RFT>." The essence of
the code there was copied from a News article posted by, IIRC, a
reliable person.

If you had looked at that URL you would have seen how an error-handler
is saved and restored - but surely that is a well-known technique in
various high-level languages?
>It was implied that one can do similarly with "all" browsers. Perhaps
one can do similarly for "createTextNode ... (fatal error to the
script)"?

Probably. But in a library type function the ability to hijack
window.onerror isn't an appealing solution.
It would not be if it could not be restored immediately.
I would prefer an approach that uses pure feature detection to detect
it. I think my best solution though is to create a variable, set it to
false, and then in an IE conditional set it to true. That doesn't
feature detect for what I want but it gets close enough as the only
browser that I know of that doesn't use createTextNode properly is IE.
If IE (with conditionals) is in fact the only failing browser, then your
method should work, AFAICS.
You will be announcing here, clearly, the posting to the "standard" URL
of each completed version of the FAQ, with its correct date and a number
higher than used ever before?

--
(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.
Dec 4 '06 #79
In article <FH**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites
>In comp.lang.javascript message <RJ**************@jgharris.demon.co.uk.
nospam.invalid>, Sun, 3 Dec 2006 13:42:20, John G Harris
<jo**@nospam.demon.co.ukwrote:
>>In article <HD**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites

<snip>
>>>But since then, in over a year, he has produced absolutely nothing,
<snip>

Isn't it time that the mistakes in js-other concerning identifiers and
semicolons were corrected ?

Perhaps. But first you have to tell me what they, in your opinion,
are, and I have to agree with you or at least believe you.
It will improve your understanding if you read the identifier and
semicolon sections again and spot the problems yourself.

John
--
John Harris
Dec 5 '06 #80
Hi Randy,

Peter Michaux wrote:
>
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.
I haven't been keeping up on this thread but is this info not going to
be included in the FAQ?

Thanks,
Peter

Dec 6 '06 #81
Peter Michaux said the following on 12/6/2006 4:14 PM:
Hi Randy,

Peter Michaux wrote:
>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.

I haven't been keeping up on this thread but is this info not going to
be included in the FAQ?
It is in section 4.34 and probably getting moved to 4.44

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 6 '06 #82
In article <FH**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites
>In comp.lang.javascript message
<RJ**************@jgharris.demon.co.uk.nospam.inv alid>, Sun, 3 Dec 2006
13:42:20, John G Harris <jo**@nospam.demon.co.ukwrote:
>>In article <HD**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites

<snip>
>>>But since then, in over a year, he has produced absolutely nothing,
<snip>

Isn't it time that the mistakes in js-other concerning identifiers and
semicolons were corrected ?

Perhaps. But first you have to tell me what they, in your opinion,
are, and I have to agree with you or at least believe you.
Here is what I would have written. You'll notice that some of my
assertions differ from some of yours.
================================================== =========
Identifiers

Identifiers give names to variables, functions, and
properties so that the compiler knows which one you're
talking about.

With some restrictions, an identifier is any combination of
letters, digits, '_', and '$' characters. Unicode letters
and a few obscure Unicode symbols are allowed. Identifiers
are case sensitive.

One restriction is that an identifier does not start with a
decimal digit, ('0' to '9'). The other restriction is that
an identifier is not one of the javascript keywords, (while,
var, in, ...), nor one of the words reserved for future use,
(class, goto, ...), nor one of the words null, true, false.

It is best not to use '$' as it makes identifiers difficult
to read and is there for use by programs that write
javascript programs.
Variables

It is better to declare each variable explicitly, as in
var x;

If this is done inside a function then x becomes a local
variable, different from any global variable and any
local variable named x in other functions. It is also
different from the local variable named x in a recursive
call of the same function.
================================================== =========
Semicolons

Some statements end with a semicolon, ';'; some end with a
close curly brackets, '}'; all other statements end with a
nested, simpler, statement. Here is an example that shows
all three cases :
if (x==0)
{ y = 0; z = 1; }
The 'if' statement ends with a block statement, { ... }.
The block statement ends with a close curly brackets. Each
of the two statements inside the block statement ends with
a semicolon.

A 'var' declaration is classified as a statement. It ends
with a semicolon.

A 'function' declaration is not classified as a statement,
though it looks much the same. It ends with a close curly
brackets.

In some cases you need not write the semicolons yourself.
In effect, the compiler will write them for you. One case
is when the semicolon is at the end of the line *and* the
beginning of the next line cannot possibly be part of the
same statement. The other case is when the semicolon is
followed by a close curly brackets. (Ignore comments when
applying these rules). Thus the example can be written as :
if (x==0)
{ y = 0
z = 1 }

In return for being able to leave out some of the
semicolons you must be careful where you put your line
endings. In particular, if a function returns a value then
the expression giving the value must start on the same line
as the 'return' keyword.

The semicolons inside a 'for' condition, (... ; ... ; ...),
cannot be omitted.

The full rules are given in ECMA 262.

================================================== =========
John
--
John Harris
Dec 10 '06 #83
In comp.lang.javascript message
<M$**************@jgharris.demon.co.uk.nospam.inva lid>, Sun, 10 Dec 2006
13:28:57, John G Harris <jo**@nospam.demon.co.ukwrote:
>In article <FH**************@invalid.uk.co.demon.merlyn.inval id>, Dr J
R Stockton <re*******@merlyn.demon.co.ukwrites
>>In comp.lang.javascript message
<RJ**************@jgharris.demon.co.uk.nospam.in valid>, Sun, 3 Dec
2006 13:42:20, John G Harris <jo**@nospam.demon.co.ukwrote:
>>>In article <HD**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites

<snip>
But since then, in over a year, he has produced absolutely nothing,
<snip>

Isn't it time that the mistakes in js-other concerning identifiers and
semicolons were corrected ?

Perhaps. But first you have to tell me what they, in your opinion,
are, and I have to agree with you or at least believe you.

Here is what I would have written. You'll notice that some of my
assertions differ from some of yours.
You're writing a simplified manual; I'm writing remarks aimed at those
who have already read as much manual or specification as they want to
(want != need).

For example, you're saying what can be used as an identifier; I'm
indicating what should be used : 'it' is a perfectly good identifier to
the parser; but it's not a good choice for a programmer/coder, as it's
difficult to search a set of pages for 'it' without getting swamped by
instances in strings, comment, and HTML-marked text.
>================================================= ==========
Identifiers

Identifiers give names to variables, functions, and
properties so that the compiler knows which one you're
I'd not think "compiler" appropriate, "parser" seems better.
--
(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
Dec 10 '06 #84
In article <eS**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites
>In comp.lang.javascript message <M$**************@jgharris.demon.co.uk.
nospam.invalid>, Sun, 10 Dec 2006 13:28:57, John G Harris
<jo**@nospam.demon.co.ukwrote:
<snip>
>>Identifiers give names to variables, functions, and
properties so that the compiler knows which one you're
Given that you understand this, I'm surprised you didn't notice the
mistake in
"Every identifier used within a function
should be declared as a var" ... .

>I'd not think "compiler" appropriate, "parser" seems better.
A parser just builds parse trees. In other languages, finding out the
meaning of each identifier is done somewhere else in the compiler, with
the parse trees as input.

As it happens, "compiler" is wrong for javascript. Finding out what an
identifier refers to is done at run-time, inside the program.

John
--
John Harris
Dec 11 '06 #85
John G Harris wrote on 11 dec 2006 in comp.lang.javascript:
As it happens, "compiler" is wrong for javascript. Finding out what an
identifier refers to is done at run-time, inside the program.
"Interpreter" is the name.

Well not quite.

In the old days, a compiler made a machine language [well not quite]
programme from the source code, that could be executed independently.

In the old days, an interpreter ran a source script while(!!!) it was
executing the script. A function could not be called if it was not defined
higher up in the script.

Nowadays, a script is first scanned by the "interpreter" at runtime(!!!),
before the real execution of some intermediate code, that is made in the
first scan by a process akin to compiling, starts.

At least, that is what I deduct from what they tell me!

Should we coin "javascript execution engine"?

I prefer "interpreter" or perhaps simply "javascript engine".

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 11 '06 #86
In comp.lang.javascript message
<X+**************@jgharris.demon.co.uk.nospam.inva lid>, Mon, 11 Dec 2006
20:27:54, John G Harris <jo**@nospam.demon.co.ukwrote:
>In article <eS**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites
>>In comp.lang.javascript message <M$**************@jgharris.demon.co.uk.
nospam.invalid>, Sun, 10 Dec 2006 13:28:57, John G Harris
<jo**@nospam.demon.co.ukwrote:

<snip>
>>>Identifiers give names to variables, functions, and
properties so that the compiler knows which one you're

Given that you understand this, I'm surprised you didn't notice the
mistake in
"Every identifier used within a function
should be declared as a var" ... .
Eschew selective or inadequate quoting, ESPECIALLY when you're not
quoting the previous News article.

And remember that you were there reading a recommendation for the use of
the language, not a requirement of the language (likewise, the regulars
here agree on the benefit of indentation to show structure and of some
other non-essential whitespace; but the javascript engine does not need
it).
>>I'd not think "compiler" appropriate, "parser" seems better.

A parser just builds parse trees. In other languages, finding out the
meaning of each identifier is done somewhere else in the compiler, with
the parse trees as input.
Maybe "interpreter" or "javascript engine" for your text, then.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Dec 12 '06 #87
In article <Xn********************@194.109.133.242>, Evertjan.
<ex**************@interxnl.netwrites
>John G Harris wrote on 11 dec 2006 in comp.lang.javascript:
>As it happens, "compiler" is wrong for javascript. Finding out what an
identifier refers to is done at run-time, inside the program.

"Interpreter" is the name.

Well not quite.

In the old days, a compiler made a machine language [well not quite]
programme from the source code, that could be executed independently.

In the old days, an interpreter ran a source script while(!!!) it was
executing the script. A function could not be called if it was not defined
higher up in the script.

Nowadays, a script is first scanned by the "interpreter" at runtime(!!!),
before the real execution of some intermediate code, that is made in the
first scan by a process akin to compiling, starts.

At least, that is what I deduct from what they tell me!

Should we coin "javascript execution engine"?

I prefer "interpreter" or perhaps simply "javascript engine".
I vote for javascript engine. Then no-one gets confused by what
interpreters do or don't do in other languages.

Question : Is your program running in a computer simulated by the
engine, or is the engine running with your program as data ?

If the latter, then you never make programming errors because your
program never runs :-)

John
--
John Harris
Dec 12 '06 #88
John G Harris wrote on 12 dec 2006 in comp.lang.javascript:
I vote for javascript engine. Then no-one gets confused by what
interpreters do or don't do in other languages.

Question : Is your program running in a computer simulated by the
engine, or is the engine running with your program as data ?
if it was simulated, there would be no effect.
If the latter, then you never make programming errors because your
program never runs :-)
No, script programmes run "on" an engine.

"Water boils in a kettel,
so the water does not boil,
the kettel does"???

;-} ;-}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 12 '06 #89
In article <$y**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites
>In comp.lang.javascript message <X+**************@jgharris.demon.co.uk.
nospam.invalid>, Mon, 11 Dec 2006 20:27:54, John G Harris
<jo**@nospam.demon.co.ukwrote:
>>In article <eS**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton <re*******@merlyn.demon.co.ukwrites
>>>In comp.lang.javascript message <M$**************@jgharris.demon.co.uk.
nospam.invalid>, Sun, 10 Dec 2006 13:28:57, John G Harris
<jo**@nospam.demon.co.ukwrote:

<snip>
>>>>Identifiers give names to variables, functions, and
properties so that the compiler knows which one you're

Given that you understand this, I'm surprised you didn't notice the
mistake in
"Every identifier used within a function
should be declared as a var" ... .

Eschew selective or inadequate quoting, ESPECIALLY when you're not
quoting the previous News article.
<snip>

Cast your gaze upon the word "identifier" in the quoted text (which came
from <URL:http://www.merlyn.demon.co.uk/js-other.htm>).

John
--
John Harris
Dec 13 '06 #90

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

Similar topics

1
by: angelag | last post by:
I am currently taking a college course in Visual Basic.Net and I am a beginner. I bought Visual Studio.Net 2003 to do my homework at home. I built my first project and e-mailed it to myself at...
3
by: Arvie | last post by:
I need some advice guys.. I am proposing that we get someone to do a complete audit/review of our Java application codebase, about 1000 JSPs/Servlets and 100 EJBs. If I get firms to submit...
5
by: angsql | last post by:
Hi, How can I tell If my sql server is MSDN or Standard or Enterprise version. Thank you AR
3
by: LP | last post by:
Hello, I am in process evaluating different reporting tools. I did use CR 9 product in the past, but I can't say that I had good experience with it. I am just curious if anyone has tried the...
1
by: relisoft | last post by:
SEATTLE, Washington. - July 12, 2006: Reliable Software® announces the upcoming release of Code Co-op® version 5.0. Code Co-op is an affordable peer-to-peer version control system for distributed...
0
by: Hans | last post by:
Hi, That's my first time to send mail to this address for asking help. Sorry for my poor english firstly. My case is like this: Many guys are using a mysql database, each guy has a database...
3
by: | last post by:
Can someone point me to some good information on creating a time-bombed version of my app for release as a demo? I know there has to be more to it than just storing the install date somewhere (i.e....
2
by: rajendiran | last post by:
project is working fine in localhost. when i upload server i got the error Server Error in '/' Application. -------------------------------------------------------------------------------- ...
0
by: corey | last post by:
Secure Bytes audit and vulnerability assessment software Secure Auditor named “Versatile tool” and earn “Five Star Ratings” in SC Magazine Group Test Secure Bytes is really pleased to share this...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.