FAQ update (roundup of pending requests - for comment)

  • Thread starter Richard Cornford
  • Start date
R

Richard Cornford

You may have noticed Jim saying that he is too busy to do an
update of the FAQ at the moment and asking for volunteers to
edit the next (and possibly future) revision. He had already
asked me if I was interested and I did volunteer, pointing out
that because I am a dyslexic with a tendency to be long-winded[1]
I might not be the best candidate for the job of FAQ editor.
However, Jim asked me to do it, which probably means that
nobody else volunteered at all.

I have successfully established access to Jim's server and am
ready to start the next revision of the FAQ. To that end I have
searched the c.l.j. archives for <FAQ**TRY> (modified here and
below so that this post and quoting responses do not show up in
future searches) and below is a roundup of requests made since
the last update and my initial thoughts on them.

I would appreciate any feedback, comments, suggestions, additions,
alternatives, etc. that anyone feels like contributing prior to
making any changes to the existing FAQ:-

<URL: http://jibbering.com/faq/ >

=====================================================================

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="Use of javascript/Jscript at Win32 DOS prompt">

I believe that an entry in Section 4 of the FAQ would be
worthwhile; just illustrating starting javascript-in-WSH
from the command line and from, say, File Manager & Internet
Explorer, and giving a well-chosen link or two.

It could include
<script type="text/javascript" src="include1.js"></script>
&
<script type="text/javascript">
...
</script><noscript> ... </noscript>
- they may be strictly HTML, but they are important to
Web use of javascript, and often given wrongly in the group.

Perhaps a possible <FAQ**TRY> could be composed here, if
Jim would like to use such.


The FAQ has not been updated lately, and new expertise has
come into the group. Might it be worth jointly reviewing
one numbered part here each week, starting I suggest at 3.1
and working round to 2.12 then 3.1 again?

Re 3.1 - I find the Pocket Reference Flanagan very useful;
it is cheaper & smaller.

Re 3.2 - Nothing to say about the intent, but I'd prefer <p>
instead of <BR> before each subsubsection.

</quote>

I see an number of FAQ addition/modification requests here:-

1. The addition of a question on using/executing WSH/JScript
for .BAT style (Windows) OS automation.

I will not be writing that entry as I have little experience
of doing that so, though I am not opposed to the idea in general,
I would need a more concrete proposal to start from. But I would
also need to see some wider support for its inclusion, as it is
not really a FAQ (just something that JavaScript authors might be
inclined to employ/exploit).

2. Something on writing formal ((x)HTML DTD valid) script tags.

If that is the correct interpretation, it has been suggested a few
times an I will return to it below.

3. Instigating a process of rolling review/modification of the FAQ
section by section.

Having just gone through the FAQ requests for the last 7 months I
think small regular updates might actually be easier but I am
reluctant to commit myself to a rolling process, at least without
evidence of general support for (and a willingness to contribute
to) the process on the part a reasonable number of regulars in the
group. (So if anyone else likes this idea, now it the time to say
so).

4. The inclusion of:-
JavaScript Pocket Reference, by David Flanagan, pub. O'Reilly
& Associates Inc. (Sebastopol, CA, US) 1998, ISBN 1-56592-521-1,
89 pages, £5.50.
-in the book recommendations in section 3.1.

I have never read (or to the best of my knowledge, set eyes upon)
that book so I could not, in good conscience, make the decision
one way or the other. But there are a lot of JavaScript books
that I have not read so I will have to adopt a policy of not
including book recommendations without widespread support (3 or
more endorsements) for the books in questions (from people who's
opinions I trust).

If anyone is in a position to express their opinion on the
suitability of "JavaScript Pocket Reference" by David Flanagan
for inclusion in the FAQ please do so. And, as usual, suggestion
for other books that would be suitable for recommendation in the
FAQ are also welcome (though authors of JavaScript books should
probably consider the generally negative attitude within this
group toward most existing JavaScript books, and therefor the
possibility of generating negative publicity that might result
form proposing volumes that may be considered unsuitable for
inclusion in the FAQ).

5. Altering the HTML version of the FAQ so that Section 3.2 is marked
up differently.

You propose P elements here and UL/LI in a later FAQENTRY request.
I would agree that that section of the FAQ comes out a bit
bunched up and could benefit from different mark-up but the HTML
version of the FAQ is generated from the same XML file as the
text versions that are posted to the group so changing the
mark-up would involve re-writing (at least parts of) the script
that generates the HTML from the XML. It looks like the change
would be feasible but I was not planning to re-write Jim's
scripts.

=====================================================================

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="Stylistic concerns for large application">

If you had looked in the regularly -posted and -cited FAQ, you
would have found no relevant occurrence of "include", which
seems a pity.

Most of my javascript date pages use include files; but start at
<URL:http://www.merlyn.demon.co.uk/js-index.htm#IF>, visit
<URL:http://www.merlyn.demon.co.uk/js-nclds.htm> and
<URL:http://www.merlyn.demon.co.uk/js-other.htm>.

<FAQ**TRY> - something on include files?

And perhaps the FAQ could link to an associated demonstration
page, intended to be most illustrative under View Source??

Might FAQ 3.2 be more readable with <ul> ... <li> ... </ul> ?

</FAQ**TRY>

</quote>

By "include files" I assume you mean JS files referenced with the
SRC attribute of script elements. I suppose that should mention
what should be in those JS files (or rather what should be omitted,
i.e. any HTML mark-up including script tags and HTML comments). How
the SRC attribute would be written in a script tag (possibly that
would be covered in an entry on the language attribute verses
type="text/javascript") and go on to describe the possibility of
document.write-ing (possibly dynamically constructed) script tags
and maybe some alternatives such as createElement("script") etc.

=====================================================================

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="parseInt .5">

I think you need to spend considerably more time reading and
testing, and less time writing.

That function returns 50 for inputs of +5 & -5; and 00 for 0.

function LZ(x) {return(x<0||x>9?"":"0")+x} // for integers

is reliable, and has the possible advantage of always returning
a string.

There is no leading zero function in the FAQ <FAQ**TRY> bur
perhaps there should be; one so often sees repetitive coding
for it.

<URL:http://www.merlyn.demon.co.uk/js-maths.htm#LZ> refers.
</quote>

I wonder if that could/should be slipped in at the end of 4.6 as
that already discusses the generation of formatted number strings.
Perhaps changing the question so that it is about less specific
number formatting.

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=pldmFJG$7t4$Ewzt@merlyn
..demon.co.uk"
author="Dr John Stockton"
subject="javascript to create dynamic HTML? (Google AdSense)">
Hmmm, well, I'm not that fanatic, but... have you found any
way to make mozilla use doublebuffering or to just paint over
the old canvas instead of first clearing it? With the current
implementation the date is flickering.

No. One reason is that I do not have, and probably have never
seen, at least since 1996, Mozilla.

But if Mozilla does flicker in some or all sorts of rewrite, that
could deserve a "how do I prevent it" <FAQ**TRY>, even if the
answer is that it is not preventable.

IIRC, can one arrange, as for the Dynamic Graphic above the
first button in <URL:http://www.merlyn.demon.co.uk/js-date3.htm>,
that only the changed digits are rewritten? The date might then
only flicker at midnight.

</quote>

I don't recall noticing any significant flickering problem with
Mozilla/Gecko browsers and I don't see any flickering on
js-date3.htm in or around the Dynamic Graphic while it is running.

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=3FDBC2B2.1020908@PointedEar
s.de"
author="Thomas 'PointedEars' Lahn"
subject="window.opener.location.reload();">

Q: My script does not work. How do I make it work?

A: "Does not work" is a useless error description. [psf 4.11]
Suggestions?

If JavaScript support is present and enabled, debug the script.


Internet Explorer
------------------

Select Internet Settings, Extras(?; last tab), then

[X] Show script errors

To use a debugger:
[_] Disable script debugging

The Microsoft Script Debugger can be downloaded from
http://www.microsoft.com/downloads/details.aspx?FamilyId=E606E71F-BA7F-4
71E-A57D-F2216D81EC3D&displaylang=en

The How-To can be found at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdbug/H
tml/sdbug_1.asp

A script debugger is also included in Microsoft Visual Studio.


Netscape 3.x+ and
Mozilla/5.0 (incl. Netscape 6+, Mozilla Firebird, ...)
-------------------------------------------------------

Type `javascript:' in the Location Bar to show the JavaScript
Console.


Mozilla/5.0
------------

In Mozilla, select Tools (menu), Web Development, JavaScript
Console. In Netscape 6+, select Extras(?), Tasks(?), JavaScript
Console.

Select Tools, Web Development, JavaScript Debugger. If
Venkman, the JavaScript Debugger for Mozilla/5.0 is not yet
installed, either update your Mozilla/5.0 and select `Debugger'
in the Custom Setup, or download and install Venkman as Cross
Platform Installation (XPI) from

<http://www.hacksrus.com/~ginda/venkman/>

How-Tos can be found there, too.


Opera
------

Select File, Preferences, Multimedia, then

[X] Enable JavaScript
[X] Open JavaScript console on error


$Foobar
--------

RTFM.

</quote>

The first point: "Does not work" is a useless error description.
Is a valid point and "does not work", as a bug report has
deservedly been subject to a lot of criticism recently. I don't
think that it should be addressed in the quick answers section
but maybe 2.3 could be modified to stress the point.

Possibly re-wording the second paragraph of section 2.3 to read:-

<draft>
Please state your question as clearly and concisely as possible,
as this will make it far easier for the other readers of the list
to understand your problems and suggest possible solutions. Try
to explain: 1. What you have done. 2. What you expected to
happen. 3. What really happened. Use the Subject: of your post
to indicate the type of problem you have, but include the
question in the body as well. 'Help!' or 'I hate Netscape!'
are not nearly as useful to contributors who do not read every
post as 'parseInt("09")!=9'.
</draft>

The second suggestion strikes me as proposing an entry in section
4 that explains how to enable error reporting on at least the
major browsers. Possibly with references to debuggers (though
venkman is already referenced in section 3.2).

As usual that is not often specifically asked as a question but
the information is frequently posted in replies so it probably
does deserve consideration for a place in section 4.

=====================================================================

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="Need help in validating the period in an email address (new
JavaScript student)">

<FAQ**TRY> The FAQ should also say that, when asking about
classwork, a poster needs to state that it is classwork
(and to present what he/she has done so far, which you did).
</FAQ**TRY>

</quote>

That would be changes to section 2.3 again, but people asking
about classwork is not that common (except just before the end of
academic years/terms).

I don't want to include this as it addresses a small minority.

It might be worth suggesting that people explain the context in
which they are asking their questions in the hope that they would
mention when it was for an educational course but my experience
suggests that often students are looking to have there homework
done for them and know that admitting that it is homework would
not produce their desired result.

Personally I like the approach to posts from students who are
attempting to pass their homework of as a real web project that
I first observed employed by Yep: posting a complete solution
using such advanced techniques (closures, OO and full
cross-browser support/fall-back) that no student who could not
solve the original problem could hope to pass it off as their
own work.

=====================================================================

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="Javascript Daylight time problem...">
You use Date in several places. *Not* handling daylight
saving is a very date specific act two times a year.

More often than that. Outside the EU, many countries (some
quite respectable) change on different dates; some, such as
Australia and New Zealand, have good reason for doing so.
I think the EU change dates, surely the EU change-instants,
are more commonly used than any others.

But at most twice per calendar year in any given location.

<FAQ**TRY> The FAQ is rather terse with its date advice; it
might help if it had an explicit date-time question, and the
one implicit in this thread might be good to choose.

</quote>

I can see some value in having a question that specifically
relates to the use of the Date object, mostly to server as a
way of channelling people interested in the Date object to more
detailed information on the subject. Daylight saving might be a
bit specialised (and maybe require too much code/explanation).

I suppose what we need is to find an expert of the Date object to
come up with a *short* general question and answer on the Date
object and some resources to reference for more details ;-)

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=20031019174853.28496.00001388
%40mb-m18.aol.com"
author="HikksNotAtHome"
subject="Client-side Javascript validation of "select multiple" for PHP
">

http://www.jibbering.com/faq/#FAQ4_25
Incorrectly states that [] are illegal characters in HTML.
It was discussed not long ago and I believe the final concensus
was that [] are in fact legal in the name.

</quote>

This one is very important as the FAQ should not be demonstrably
incorrect. Currently it reads:-

4.25 My element is named myselect[] , how do I access it?

Form elements with any "illegal" characters can be accessed
with formref.elements["myselect[]"] - These characters are
illegal in the standard (x)HTML doctypes, so you should try
to avoid them as browsers may perform incorrectly though.

The first "illegal" could stay as it could be argued that the
characters are illegal in some contexts (JavaScript identifiers)
but the second sentence must be re-worded. Maybe:-

<draft>
"These characters are illegal within ID attributes in the
standard (x)HTML doctypes and javascript Identifiers, so you
should try to avoid them as browsers may handle them
incorrectly."
</draft>

=====================================================================

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="How to use window.open() ?">

By composing text within a right margin of about 72 characters,
in accordance with standard Usenet recommendation, you can make
your material more readily readable to those with standard
72-column eyes or 80-column display windows.

<FAQ**TRY> Jim, I don't see a mention of posting margin or
line-wrap in 2.3 </FAQ**TRY>.

</quote>

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="Need special kind of countdown timer ">

Please set your right margin at about 72 characters. It is
easier to read, and quotes better in standards-compliant
newsreaders. See references in FAQ. <FAQ**TRY> Mention margin
in 2.3? </FAQ**TRY>

</quote>

Jim seems to be resistant to mentioning margins in section 2.3
and I am also inclined to leave that out. As it is there is a
constant struggle to get people to follow the existing posting
guidelines in section 2.3. The people who will not respect the
existing guidelines are not going to be influenced by a specified
margin and the people who do follow them don't seem to take much
persuading to use a suitable margin.

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=fK6b+sBp0j6+EwiN@merlyn
..demon.co.uk"
author="Dr John Stockton"
subject="Force user to open in IE">
I'd like to know if there is a way to force a user to open
a link on my page in I.E. even if they are using Netscape.?

Not even Bill Gates can do that directly.

Vcards are merely a source of annoyance for many readers.
<FAQ**TRY>?

</quote>

Of all the possible sources of annoyance? I am not inclined to
include this.

=====================================================================

<quote
cite="http://groups.google.com/[email protected]"
author="Lasse Reichstein Nielsen"
subject="dependable select boxes">

<FAQ**TRY>
You can add options to a select element using "selectRef.add"
and remove them with "selectRef.remove", although these
functions are not present in older browsers.

You need to keep the new data somewhere else, probably as an
array of text/value pairs.

The following function changes the options of a select element:
---
function setOptions(selectRef,optArray) {
var optsRef = selectRef.options;
// Clear old options
optsRef.length = 0;
// Insert new options
for (var i = 0 ; i < optArray.length-1 ; i += 2) {
var opt = new Option(optArray,optArray[i+1]); // text,value
optsRef[optsRef.length] = opt;
}
}
---
You can use this function from the onchange handler of another
select element.
</FAQ**TRY>

</quote>

Successfully handling the manipulation of option elements in a select
element is one of those things that probably deserves considerably
more information than would fit well in a quick answer. There are
always the design and fall-back/clean degradation issues in addition
to the pure mechanics of creating and appending new Option elements.

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=TC$YsJEdhqC$EwXo@merlyn
..demon.co.uk"
author="Dr John Stockton"
subject="Question ">
What I'm trying to do is have the web page placed on a web
server and have the list automatically update every time a
file is uploaded. Is there a way to do that?? The list will
be on the web page.

That requires server-side coding.

That's fully on-topic AIUI; OTOH the _default_ assumption here
is that code is for execution in an Internet Web browser.
See FAQ 2.2 para 1.

<FAQNONENTRY> - Jim, I can't see the new FAQ on the Web. ???

<FAQ**TRY> At the end of that para, "... which host ..." - in
the default case, where the javascript is used in a Web browser,
a major point is that the author does not really know which host
will be used. Could it be rephrased? "... which type of host ..."
seems better but may not be best.

</quote>

Presumably "type of host" refers to web browsers, servers,
WSH and others, while "host" alone might imply a single
browser. I will change that, though I would be open to other
alternative wordings.

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=20030827045359.11891.00000254
%40mb-m11.aol.com"
author="HikksNotAtHome"
subject="Scrolling Table - Which browsers support this code ">

http://www.metalusions.com/backstage/articles/8/

if(document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id];
}
}

<FAQ**TRY>
document.getElementById for IE4?
</FAQ**TRY>

Thoughts and comments?
Specifically, are there any cases where the above fails in IE4?
Or, any other browsers that will pass the test other than IE4?
I recall Jim mentioning one that supported document.all and
document.layers at the same time.

</quote>

<quote
cite="http://groups.google.com/groups?selm=20030624173732.17796.00001037
%40mb-m15.aol.com"
author="HikksNotAtHome"
subject="Script Won't Upload in Netscape">

<FAQ**TRY>
http://www.metalusions.com/backstage/articles/8/
</FAQ**TRY>

I posted that URL a while back, don't remember if I offered it
as an FAQEntry or not though.

if(document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id];
}
}

</quote>

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="prototyping document.getElementById">
I'm thinking of prototyping document.getElementById for those
browsers that understand document.all but not
document.getElementById (IE4).

Is that a reasonable thing to do? Suggestions?


Article
From: (e-mail address removed) (HikksNotAtHome)
Newsgroups: comp.lang.javascript
Date: 24 Jun 2003 21:37:32 GMT
Subject: Re: Script Won't Upload in Netscape
Message-ID: <[email protected]>

included

if (document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id];
}
}

That looks worth a <FAQ**TRY> to me; and I put it in my
<URL:http://www.merlyn.demon.co.uk/js-other.htm>
as an example of Object Detection.

</quote>

I wonder whether including this is a good idea. I would handle
IDed element retrieval with a specific function that either
handled the fall-back from getElementById itself or had been
set up during configuration to handle the fall-back. I generally
don't like attempts to "normalise" browsers to a homogenised DOM.

Opinions?

=====================================================================

<quote
cite="http://groups.google.com/[email protected]"
author="Lasse Reichstein Nielsen"
subject="Javascript in netscape navigator">

<FAQ**TRY>
Why doesn't the global variable "divId" refer to the
element with id="divId"?

It does in Internet Explorer, but not in *many* other browsers.
The recommended way of referring to an element with id="foo" is
document.getElementById("foo")
In order to support older browsers that doesn't implement this
W3C DOM method, fallback to proprietary features can be used. In
Internet Explorer 4 (and WebTV?), you can use document.all["foo"] .
In Netscape 4, maybe you can use document.layers["foo"] ,
but only if the element is absolutely positioned (or created with
the Netscape 4 proprietary <layer> tag).


<URL:http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom_access</FAQ**TRY>

</quote>

In one form or another this proposal is going into the FAQ. I
originally proposed a longer alternative to Lasse's but Jim
favoured making it considerably shorter and omitting all the
references to fall-back.

My current version is:-

<draft>
4.41 Why doesn't the global variable "divId" always refer to
the element with id="divId"?

A common shortcut(introduced by IE and reproduced in some
other browsers) in accessing DOM elements that have ID
attributes is to use a provided global variable with the same
name as the element's ID string. However, the best approach is
the document.getElementById method, which is part of the W3C
DOM standard and implemented in modern browsers (including
IE from version 5.0). So an element with id="foo" can be
referenced with:-

var el = document.getElementById("foo");


<URL:http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom_access</draft>

As usual, comments, criticisms, corrections and alternatives are
welcome.

Having decided to remove Lasse's consideration of fall-back from this
entry it might be worth re-considering Randy's IE 4 fall back for
getElementById.

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=D25cBcE+0u8+EwC7@merlyn
..demon.co.uk"
author="Dr John Stockton"
subject="Downloadnig HTML source code">
File>Save As will give it to you, very easily, in MSIE's
warped way of rendering but it adds some extra code to it
and messes up the original folder organization. Netscape 7
seems to save it as it is sent by the server though.


Given the degree of variation in what people say happens (and
that in what can happen), and the frequency with which viewing
the source of a Web page is recommended in this group, ISTM
that a <FAQ**TRY> on viewing source could be justified, perhaps
adjacent to that on hiding source.

Perhaps a short paragraph outlining the possibilities, and if
available a link to elsewhere.



FAQ 4.38 is rather brief, from the point of view of an off-line reader;
could LB produce a sentence describing the basis?

</quote>

I am unsure what an entry on viewing source would say.
Server-scripters often don't seem to appreciate that debugging
client-side JavaScript is better done using the source the
browser receives instead of the server-script that generates
it, but do that many people need to be told how to view the source?

4.38 will have to stay as it is unless Laurent (or someone else)
comes up with an additional sentence (probably literally). And I
suspect that the subject could not be usefully addressed in just
one sentence, or any statement that was sufficiently short.

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=Lc$+rFC8alK$EwFy@merl
yn.demon.co.uk"
author="Dr John Stockton"
subject="Script tag - language version">
Use the type attribute instead:

<script type="text/javascript">

<FAQ**TRY> That (slightly expanded) is now a FAQ candidate,
IMHO.

</quote>

<quote
cite="http://groups.google.com/groups?selm=20031008225410.21542.00000503
%40mb-m02.aol.com"
author="HikksNotAtHome"
subject="Two Questions about the Following Block of Code">
<script language="JavaScript">
Language attribute is deprecated in favor of the type
attribute: text="type/javascript"

<FAQ**TRY>
type="text/javascript" in favor of language="javascript"
</FAQ**TRY>

Not sure on a wording, but its seen a lot here :-(

</quote>

This certainly is frequently mentioned so it might deserve an entry.

So would the section 4 question be "How do I write HTML 4 valid
script tags?" or "How do I write script tags?"? With the latter
having to go into more detail on the LANGUAGE attribute (and
possibly language version numbers and their associated problems).

=====================================================================

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="Money Format Problem">

Revised <FAQ**TRY> 4.6

4.6 How to convert a Number into a String with exactly 2
decimal places?

For example, to format 6.57634 to 6.58, 6.5 to 6.50,
and 6 to 6.00?

Rounding of x.xx5 is uncertain, as such numbers are not
represented exactly.

N = Math.round(N*100)/100 only converts N to a Number of
value close to a multiple of 0.01; but document.write(N)
does not give trailing zeroes.

ECMAScript Ed. 3.0 (JScript 5.5 (but buggy) and JavaScript 1.5)
introduced N.toFixed, but that <test & describe what it does> .

Much code for trailing zeros fails for some numbers
(e.g. 0.07). The following works successfully :

BOX
BOX

Method toFixed in the box above is intended to do what
browser toFixed ought to do, not to be equivalent.


// Note that code I now use, at
<URL:http://www.merlyn.demon.co.uk/js-round.htm#GC>,
differs a little from what is in the FAQ.

</quote>

The first request is to describe and test what toFixed actually
does rather than just asserting that it is buggey in its
implementations (4th paragraph). That sounds like it could be
quite a large addition.

Adding a final note saying that the assigned
Number.prototype.toFixed function is not equivalent to the
original doesn't strike me as necessary.

=====================================================================

<quote
cite="http://groups.google.com/[email protected]
emon.co.uk"
author="Dr John Stockton"
subject="New to java">
You do not need any javascript to do this. Just standard
HTML with a bit of CSS to control the background image on
mouseover.

There being questions which can quite reasonably be considered,
/a priori/, to be javascript questions, but for which answers
such as the above are appropriate, ISTM that it would be well
<FAQ**TRY> for the FAQ to include, described as such, one or
two links to well-written introductory CSS information.

</quote>

Perhaps an opportunity to assert the general principal that if
something can be done without JavaScript then it should be done
without JavaScript. I don't see an easy way of making that
point, for example, suppose the question was "What is the best
strategy for using JavaScript on the Internet?". That might
certainly mention the preceding principal (and reference CSS as
a result) along with such things as treating JavaScript as a
means of providing optional enhancements and clean degradation.
Then again it might just result in an extended argument about
what the "best strategy" is.

Anyone care to start the ball rolling?

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=20030608204652.04207.00000619
%40mb-m01.aol.com"
author="HikksNotAtHome"
subject="FAQ Updates">

Any chance of an added entry on the problems, and possible
solutions, to popup windows? Or even just links to articles
on the problems with using it?

Whats wrong with window.open(...)?

</quote>

At the time I though that this suggestion deserved more
consideration. The opening of windows with JavaScript
certainly is frequently the subject of questions on the
group and is frequently unwisely handled by script authors.

To start with we would need some resources to reference on
the subject, and preferably not pages that gloss-over the
problems of opening window. For that purpose
Lasse Reichstein Nielsen's page:-

<URL: http://www.infimum.dk/HTML/JSwindows.html >

-is probably the best candidate that I have seen. While it is
not as negative about the idea of opening new windows as I
would be, it does not conceal the potential problems and even
directly states that window opening is widely considered
unsuitable for anything important. It would be nice to be able
to also add a page on achieving pop-up like effects without
using new browser instances (or modal dialogs).

The question it self could be fairly simple:-
<draft>
4.nn How do I open a new window with JavaScript?

New windows can be opened on browsers that support the
window.open function and are not subject to the action
of any pop-up blocking mechanism with code such as:-

if(window.open){
wRef = window.open("http://example.com/page.html", "windowName");
}

<URL; resource references>
</draft>

But there is a great deal omitted from the above, including any
consideration of the window features list.

=====================================================================

<quote
cite="http://groups.google.com/groups?selm=v0$3h1FuCs+$Ewzm@merl
yn.demon.co.uk"
author="Dr John Stockton"
subject="Environment Variables in WSH JS">

Aside : <FAQ**TRY> 2.11 : "over 5 years" is IMHO ambiguous.
Suggest "more than 5 years" or "for 5 years", whichever is meant.

</quote>

Yes, I will change that to "more than 5 years".

=====================================================================

The code used in section 4.15 has come in for a lot of comment lately.
While it is not the code I would use for the task, the existing code
is short, will work successfully in browsers that support innerHTML
and the text includes the pertinent caveats. So I am inclined to
leave it as it is for the time being, unless a strong feeling that
it should be changed (baring in mind the need for brevity) is
expressed.

=====================================================================

Richard.

[1] The only practical consequence is that I will not be
offended if anyone feels like criticising/correcting my spelling
and/or grammar. And I also won't object to suggestions of more
concise wordings where available.
 
J

Jim Ley

He had already
asked me if I was interested and I did volunteer, pointing out
that because I am a dyslexic with a tendency to be long-winded[1]

People elsewhere have said that I have the worst grammar they have
ever seen, so I don't think you can do any worse than me. Brevity can
be forced on you once you realise how many lines the post is after
processwenttxt.wsf is run.
I would appreciate any feedback, comments, suggestions, additions,
alternatives, etc. that anyone feels like contributing prior to
making any changes to the existing FAQ:-

<URL: http://jibbering.com/faq/ >

One possible suggestion was moving the domain of the FAQ to improve
search engine placement, e.g. http://javascript-faq.jibbering.com/
or similar, I can host whatever but currently only have domains
jibbering.com|org/spurn.org/svg-components.org to hand, it may not be
wise due to the risk losing any google love we've got (google
generally doesn't mind proper redirects to a new canonical url but...)
If anyone is in a position to express their opinion on the
suitability of "JavaScript Pocket Reference" by David Flanagan
for inclusion in the FAQ please do so.

Looking at it in Borders it's a broadly accurate pocket reference, if
you want such a thing it's suitable, I'm not sure how useful it
genuinely is though for someone looking to learn, but it does do what
it says on the tin.

By "include files" I assume you mean JS files referenced with the
SRC attribute of script elements.

Would also need to mentione "xlink:href" here for other non-HTML
versions of script I think. (it's a FAQ elsewhere than here, and
could be usefully addressed in a few words)
<draft>
"These characters are illegal within ID attributes in the
standard (x)HTML doctypes and javascript Identifiers, so you
should try to avoid them as browsers may handle them
incorrectly."
</draft>

I like this.
Successfully handling the manipulation of option elements in a select
element is one of those things that probably deserves considerably
more information than would fit well in a quick answer. There are
always the design and fall-back/clean degradation issues in addition
to the pure mechanics of creating and appending new Option elements.

It's amazing how much trouble this has been over the years...
<FAQNONENTRY> - Jim, I can't see the new FAQ on the Web. ???

This reminds me, I need to change the script, or tell you something
else Richard, remind me if I forget.
I recall Jim mentioning one that supported document.all and
document.layers at the same time.

Omniweb mentioned in
http://jibbering.com/faq/browsers.txt
Perhaps an opportunity to assert the general principal that if
something can be done without JavaScript then it should be done
without JavaScript.

I don't wholly agree with this, for example there are many things
which CSS fails more disastrously at than the well authored javascript
approach.
Then again it might just result in an extended argument about
what the "best strategy" is.

Anyone care to start the ball rolling?

"Don't do anything that stops people accessing your content/using your
site..."

There's my notes so far...

Jim.
 
R

Richard Cornford

Another way to enable error messages in IE6:

Double click the Yellow ! in the lower left corner
Check the "Always display this message when an error occurs in
the page" checkbox.

With the way that MS has changed the path to enable/disabling
it in IE4/5/5.5/6, the above seems to be a simpler way to tell
someone how to enable the error messages.

I was thinking much the same. I would be worth quickly mentioning that
it was also available for activation under one of the menus but paths
through menus and dialogs are not as easy to describe (especially as
text).

I would also favour describing typing "javascript:" into the location
bar on Netscape/Mozilla/Gecko browsers rather than going into details on
the menus and preferences dialogs.
if(document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id];
}
}
I wonder whether including this is a good idea. I would
handle IDed element retrieval with a specific function
that either handled the fall-back from getElementById
itself or had been set up during configuration to handle
the fall-back. I generally don't like attempts to
"normalise" browsers to a homogenised DOM.

Opinions?

I don't see where thats normalising the browser. To me, it
simply makes it simpler to write scripts that fallback to
IE4 instead of back to IE5

Well, its just one feature so it is a bit extreme to call it
normalising, but it is a step (albeit a small one) in that direction.
(unless its found to be defective in IE4 somewhere)

I can only see this code failing to be equivalent to getElementById if
there are multiple elements with the same ID on a page, or when an
element has the same string assigned to its NAME attribute as has been
assigned to the ID of a different element. The first is invalid HTML
(which IE puts up with) and the second is actually a problem for some IE
implementations of getElementById anyway.
by defining a function that works in IE4. Even with that
snippet, the object detection routines should still be
used to ensure that what you are trying to do works. It
just seems easier than something like this:

if (document.getElementById){
//statements here
}
else if (document.all){
//same statements here but using document.all instead of
// document.getElementById
}

Yes its easier than that, but recognising that the task that needs to be
handled differently on different browsers is just the IDed element
retrieval would suggest that just that task could be handed off to a
separate dedicated function so there is no repetition of blocks of
statements in the branches for each condition.

As the above function is just an easy way of handling fall-back for
browsers that have a document.all collection but no getElementById
method I still don't want to give it a dedicated entry in section 4 (at
least without some discussion of similar fall-back for other known
browsers. On the other hand, see my proposal for 4.15 in my reply to Dr
John Stockton for one possible compromise.

shouldn't we be able to critique that page as well? (Sorry Jim)

Changing that page is outside of my remit. :)

"Should I use the language attribute or the type attribute in my
script tags?"
<snip>

Maybe "and/or" instead of "or". That would narrow the question down
quite a bit, and so make for a short answer. It would also be a very
(x)HTML browser specific answer. I was wondering whether it would be
practical to address Dr John Stockton's concerns about including files
within this entry, but that won't be possible if it is narrowed down to
just the attributes.

Hmm, I might just have to write some versions and see what people think.

Thanks for your thoughts.

Richard.
 
R

Richard Cornford

People elsewhere have said that I have the worst grammar
they have ever seen, so I don't think you can do any worse
than me.

The extent to which my grammar may be acceptable is more a result of
having articulate parents and decades of listening to BBC Radio 4 than
anything the British education system can claim credit for. I don't know
any formal English grammar rules, I don't recall any of my school
"English teachers" ever mentioning anything substantial relating to
their subject at all.
Brevity can be forced on you once you realise how
many lines the post is after processwenttxt.wsf is run.

I am very aware of the risk (and consequences of) bloating the FAQ. :)

One possible suggestion was moving the domain of the FAQ to
improve search engine placement, e.g.
http://javascript-faq.jibbering.com/
or similar, I can host whatever but currently only have domains
jibbering.com|org/spurn.org/svg-components.org to hand, it may
not be wise due to the risk losing any google love we've got
(google generally doesn't mind proper redirects to a new canonical
url but...)

When you where debating this with Dr John Stockton (on
microsoft.public.scripting.jscript as I recall) I did a google search
and the FAQ came out 4th, which didn't seem too bad (or as bad as Dr
John Stockton's attempt).
Looking at it in Borders it's a broadly accurate pocket reference,
if you want such a thing it's suitable, I'm not sure how useful it
genuinely is though for someone looking to learn, but it does do
what it says on the tin.

Maybe someone with the 2nd or 3rd edition of JavaScript: The Definitive
Guide might want an up to date reference without the rest of the book,
but I agree that it is not a book for learners of JavaScript. I am still
not inclined to include it.

This reminds me, I need to change the script, or tell you
something else Richard, remind me if I forget.
OK.



I don't wholly agree with this, for example there are many things
which CSS fails more disastrously at than the well authored
javascript approach.

You are thinking of things like the CSS "alternative" to, say, image
rollover scripts that aren’t (yet) nearly as well supported as the
JavaScript approach? I was thinking more of things like using JavaScript
to detect the browsers and then choose a stylesheet to reference in link
elements (often with no default for when JavaScript is not available),
which is something I think is better addressed with CSS alone.
"Don't do anything that stops people accessing your
content/using your site..."

In which "(or search engine robots)" cold be inserted after "people", if
they could be said to "use" a site.
There's my notes so far...

Thanks, I still have plenty to think about before settling on any final
changes.

Richard.
 
J

Jim Ley

When you where debating this with Dr John Stockton (on
microsoft.public.scripting.jscript as I recall)

Was it, I'm not currently reading there, although I did for awhile
again on the wine covered laptop, I guess it could've been then.
I did a google search
and the FAQ came out 4th, which didn't seem too bad (or as bad as Dr
John Stockton's attempt).

I'd've thought http://javascript-faq.jibbering.com/ that kept the
current google love of the FAQ would get even better than that, but
I'm not sure it's really worth the trouble, especially as it's extra
risk of me forgetting to set up the vhosts if I change/reinstall
servers and server is getting a new disk real soon now, well when I
can get one shipped down there, and get it nstalled it, it's currently
very ill, new server sometime soon. Okay, not really a new server, a
wine covered laptop...

Jim.
 
J

Jim Ley

One thing that I have found out about Jims HTTPRequest page. I started
tinkering with it on a whim, and found out (via Martin Honnen, <URL:
http://tinyurl.com/2f2hc /> is to the thread where he made it work in Mozilla
for me.

Hey, c'mon I wrote it almost 2 years ago, and I'm still not interested
enough in mozilla outside web security to bother looking into it.
I'll update it to point to the thread, at some point, if I find some
bandwidth.
Not in the FAQ but if the FAQ links to a page that explains something,
shouldn't we be able to critique that page as well? (Sorry Jim)

My pages can always be critiqued, they're basically rubbish, not only
that, but patches are always welcome, and sometimes even apply them
:)

Jim.
 

Ask a Question

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

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

Ask a Question

Members online

Forum statistics

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

Latest Threads

Top