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

FAQ Suggestion

P: n/a
Tried mailing the FAQ maintainer but the mail bounced.

The FAQ entry of topic:
http://www.jibbering.com/faq/#FAQ4_15

DocDom = (document.getElementById?true:false);
DocAll = (document.all?true:false);
DocStr=''
if (DocAll) DocStr="return document.all[id]"
if (DocDom) DocStr="return document.getElementById(id)"
GetRef=new Function("id", DocStr)
if (DocStr=='') { DynWrite=new Function("return false") } else {
DynWrite=new Function("id", "S", "GetRef(id).innerHTML=S; return
true")
}

Is a very poor quality example. Anyone reading that code who knows
what they are doing would probably consider the advice in the document
worthless.

It should be revised to not use the function constructor, for one. It
should definitely not declare variables without the var keyword. The
DocDom variable is also questionable. Does "DocDom" being true imply
something other than "document.getElementById" exists?

The explanation before the example is sufficient.

It would be a good idea to add something about script tag insertion.
This comes up fairly often.

========================================
SCRIPT tags inserted with innerHTML will not be evaluated in most
circumstances. Appending a
script tag will cause the script to be executed in most browsers.
--------------------------------------------------------
[example]
--------------------------------------------------------

========================================
Aug 8 '08 #1
Share this Question
Share on Google+
15 Replies


P: n/a
On Aug 8, 10:41*am, dhtml <dhtmlkitc...@gmail.comwrote:
Tried mailing the FAQ maintainer but the mail bounced.
The best method has been to follow the advice in FAQ 5:

<URL: http://www.jibbering.com/faq/#FAQ5 >
Constructive criticism is welcome but insufficient to get entries
changed. The most successful process has been to post the suggested
revised entry here with reasons for the update.

The FAQ maintainer should then update the FAQ (or not) depending on
the response the post. If the current maintainer continues to be
elusive, perhaps it's time to look for a new volunteer.
--
Rob
Aug 8 '08 #2

P: n/a
On Thu, 7 Aug 2008 17:41:13 -0700 (PDT), dhtml
<dh**********@gmail.comwrote:
>Tried mailing the FAQ maintainer but the mail bounced.
the ji*@jibbering.com one? what message? ji*****@gmail.com also
works and has a different set of filtering/spam protection on it.

I do agree on the updates - do we have a new maintainer that I should
give access too?

Cheers,

Jim.
Aug 8 '08 #3

P: n/a
On Aug 8, 3:41*am, j...@jibbering.com (Jim Ley) wrote:
On Thu, 7 Aug 2008 17:41:13 -0700 (PDT), dhtml

<dhtmlkitc...@gmail.comwrote:
Tried mailing the FAQ maintainer but the mail bounced.

the j...@jibbering.com *one? *what message? *jim....@gmail.com also
works and has a different set of filtering/spam protection *on it.
I used the gmail one the second time. The mail I sent to Randy Webb
(cl****@comcast.net) bounced.

The one I sent to your gmail account did not.
I do agree on the updates - do we have a new maintainer that I should
give access too?
I don't think we do. Do we?
>
Cheers,

Jim.
Aug 8 '08 #4

P: n/a
In comp.lang.javascript message <8c1dcb4b-f395-4ff4-aa26-5913024bdd3a@y1
9g2000prn.googlegroups.com>, Thu, 7 Aug 2008 17:41:13, dhtml
<dh**********@gmail.composted:
>Tried mailing the FAQ maintainer but the mail bounced.
That shows why FAQ 5.2 needs a change.
>The FAQ entry of topic:
http://www.jibbering.com/faq/#FAQ4_15

DocDom = (document.getElementById?true:false);
DocAll = (document.all?true:false);
DocStr=''
if (DocAll) DocStr="return document.all[id]"
if (DocDom) DocStr="return document.getElementById(id)"
GetRef=new Function("id", DocStr)
if (DocStr=='') { DynWrite=new Function("return false") } else {
DynWrite=new Function("id", "S", "GetRef(id).innerHTML=S; return
true")
}

Is a very poor quality example. Anyone reading that code who knows
what they are doing would probably consider the advice in the document
worthless.
Clearly postfix ?true:false should be replaced by prefix !! .
>It should be revised to not use the function constructor, for one. It
should definitely not declare variables without the var keyword.
If the whole is encased in a function (as I (an original *user*) did),
the lack of var makes then usefully global.
The
DocDom variable is also questionable. Does "DocDom" being true imply
something other than "document.getElementById" exists?

The explanation before the example is sufficient.
One wonders whether "insufficient" was intended.
The common way now is AIUI to use either DOM methods or less modern
document.getElementById(ID).innerHTML = S

In either case, the code should, for overall brevity and structure, be
encapsulated in, say,
function Wryt(ID, S) { /* ... */ }
and it would be good to see that in the FAQ.

If it is necessary to support browsers without document.getElementById,
one can include something like
if (document.all && !document.getElementById) {
document.getElementById =
function(id) { return document.all[id] } } ,
the documentation of which needs a note indicating that and how it is
not fully equivalent.

--
(c) John Stockton, nr London, 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)
Aug 8 '08 #5

P: n/a
On Aug 8, 12:39*pm, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
In comp.lang.javascript message <8c1dcb4b-f395-4ff4-aa26-5913024bdd3a@y1
9g2000prn.googlegroups.com>, Thu, 7 Aug 2008 17:41:13, dhtml
<dhtmlkitc...@gmail.composted:
Tried mailing the FAQ maintainer but the mail bounced.

That shows why FAQ 5.2 needs a change.
Sure.
Clearly postfix *?true:false *should be replaced by prefix !! .
I don't think the DocDom variable needs to be declared at all. I don't
think this needs to be function, either. el.innerHTML = s is
sufficient.

Declaring global variables inside a function by omitting var makes the
globals hard to notice. It looks like a mistake from the careful eye,
and would go unnoticed by a quick lookover. It can also cause an error
if there is an element with the same name

The common problem is the variable i used in loops;

Douglas Crockford actually advises not using var:
http://yuiblog.com/blog/2008/04/16/g...tion-part-two/

But provides no explanation other than: "There's a bug in IE."
var pity = this.pity || {};alert(pity)

No explanation of what happens in IE or what should happen.

The problem with omitting var in IE is that it can create conflict
with objects that get added to the global object as apparently
readonly.

<div id=Menu></div>
<script>
Menu = {};
</script>

Error in MSIE.

However:
<div id=Menu></div>
<script>
var Menu = {};
</script>

Will not cause an error.

IE8 could fix this for standards mode, and only fall back to the buggy
behavior for quirks mode, but they probably won't. They could not
reproduce the bug I filed on this.
>
The explanation before the example is sufficient.

One wonders whether "insufficient" was intended.
No, I meant 'sufficient' there's just a simple explanation of
something like:
el.innerHTML = "hello <em>world</em>"; or something like that. It
seemed sufficient. There's no need to write a helper function for
innerHTML. It woul only make the code slower and more complex.
>
The common way now is AIUI to use either DOM methods or less modern
* * * * document.getElementById(ID).innerHTML = S
Right.
>
--
Aug 9 '08 #6

P: n/a
dhtml <dh**********@gmail.comwrote in news:1616178e-b10c-491f-8e5a-
10**********@w1g2000prk.googlegroups.com:
>
Declaring global variables inside a function by omitting var
Good Lord! This explains a lot of my problems. I always thought that they
were global only if declared explicitely as a var *outside* of all
functions.

Thanks for the tip! I thinks it's time for a little code review. In any
case I usually declare everything in functions, mostly out of habit from
using more restrictive languages, so it should not turn up a lot of
changes.

One little question though. When does the global definition dissapear? The
reason I ask is because am restricted to using static pages, and where cgi
or asp should really be used I instead have a habit of building a new page
into a string and then using document.write if I need to change the <head>
section or simply changing the innerHtml on an element which comprises the
entire <bodysection. I have had "issues" in the past regarding globals in
the resulting javascript.

Do variables declared within event handlers (i.e. <img onLoad="blah blah"
get treated the same way? (i.e. do they become global?)
Aug 9 '08 #7

P: n/a
Mike Duffy wrote:
dhtml <dh**********@gmail.comwrote in news:1616178e-b10c-491f-8e5a-
10**********@w1g2000prk.googlegroups.com:
>
One little question though. When does the global definition dissapear? The
reason I ask is because am restricted to using static pages, and where cgi
or asp should really be used I instead have a habit of building a new page
into a string and then using document.write if I need to change the <head>
section or simply changing the innerHtml on an element which comprises the
entire <bodysection.
That's not a good way to write maintainable code.
I have had "issues" in the past regarding globals in
the resulting javascript.

Do variables declared within event handlers (i.e. <img onLoad="blah blah"
get treated the same way? (i.e. do they become global?)
Yes, Identifiers are resolved the same way. If no Identifier is found,
it is a global assignment.
Aug 9 '08 #8

P: n/a
Mike Duffy wrote:
dhtml <dh**********@gmail.comwrote [...]:
>Declaring global variables inside a function by omitting var

Good Lord! This explains a lot of my problems. I always thought that they
were global only if declared explicitely as a var *outside* of all
functions.
In a way, you are correct, and "dhtml" is not (which has been explained
before here). Because what has not been declared a variable will never
magically become one. Instead, use of an undeclared identifier left-hand
side in an assignment leads to its resolution along the scope chain; if no
object in the scope chain has a property with that name, the Global Object
will be augmented with one. The most important difference to a global
variable is that this new property can be deleted.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Aug 9 '08 #9

P: n/a
dhtml <to****@comcast.netwrote in
news:bp******************************@comcast.com:
Mike Duffy wrote:
>dhtml <dh**********@gmail.comwrote in news:1616178e-b10c-491f-8e5a-
10**********@w1g2000prk.googlegroups.com:
>
That's not a good way to write maintainable code.
You're telling me! One of the hardest things is working with strings,
because you are building the html into strings which contains the javacript
within quotes, which itself needs to have quoted material. It gets
especially tricky when you want to define on-the-fly html tags with in-line
event handlers.

Of course, if I had a business-related site I would pay extra and use ASP /
AJAX / CGI.

If anyone is interested, you need to do a "document.close", then
"document.open" before the "document.write" if you want a web page with a
new <headsection. You can see an example of a dynamically-generated page
on a static server if you go to my javascript phone poem generator. Go to
my poetry page at:

http://pages.videotron.com/duffym/poetry.htm

and take the exam at the bottom of the page.
Aug 9 '08 #10

P: n/a
Thomas 'PointedEars' Lahn wrote:
Mike Duffy wrote:
>dhtml <dh**********@gmail.comwrote [...]:
>>Declaring global variables inside a function by omitting var
Good Lord! This explains a lot of my problems. I always thought that they
were global only if declared explicitely as a var *outside* of all
functions.

In a way, you are correct, and "dhtml" is not (which has been explained
before here). Because what has not been declared a variable will never
magically become one. Instead, use of an undeclared identifier left-hand
side in an assignment leads to its resolution along the scope chain; if no
object in the scope chain has a property with that name, the Global Object
will be augmented with one. The most important difference to a global
variable is that this new property can be deleted.
Thomas is technically correct.

It follows from:
11.13.1 Simple Assignment (= )
and
8.7.2 PutValue(V, W)

Where PutValue step 6, a property is assigned to the global object.

However, MSIE has different behavior, depending on the identifier.

1.
<div id='Menu'></div>
<script>
this.Menu = {} ;
</script>

No Error

2.
<div id='Menu'></div>
<script>
Menu = {} ;
</script>

Error in IE8 in standards mode.

https://connect.microsoft.com/IE/fee...dbackID=354814
Status Closed (Not Reproducible)

Assigning a property to the global object works without error in IE
(example 1) but in contrast example 2 causes an error.

Why does Douglas Crockford advise not using var for globals? What's the
IE bug he mentions in passing?

http://yuiblog.com/blog/2008/04/16/g...tion-part-two/

| JavaScript provides three ways of declaring a global variable,
| and they all have problems.
....

| IE gets the second form wrong, so that responsibly
| adaptive programs fail when using constructs like
|
| var pity = this.pity || {};

What's this bug in IE?

All globals should be declared explicitly (using var). It's explicit and
it avoids the bug I mentioned (above). Global functions can be declared
with a FunctionDeclaration.

Garrett
>
PointedEars
Aug 9 '08 #11

P: n/a
Jim Ley wrote:
I do agree on the updates - do we have a new maintainer that I should
give access too?
We might have one.

As I have said in [1] before, I have been considering to contribute in that
way, too, for quite a while. That started when the current maintainer
refused to think about any changes based upon their own initiative and even
argued against posting conventions recommended in the FAQ[2], which is not
what I think a responsible FAQ maintainer should do.[3]

At that time, I actually considered supporting him in the task rather than
taking over, but I had much too little free time on my hands even for that.

This has changed now that I am dealing with fewer but larger projects in my
job, and particularly at this time of year where most customers are on
holiday.

Therefore, I am hereby volunteering for the job.

As I have said repeatedly, I second that the FAQ desperately needs
improvement in several places (e.g. [4]), and I am going to do my
best to make it so.

[1] <news:47************@PointedEars.de>
[2] <news:47**************@PointedEars.de>
[3] <news:47**************@PointedEars.de>
[4] <news:46**************@PointedEars.de>
<news:47**************@PointedEars.de>

Some things about me:

- IIRC, I have been dealing with JavaScript, JScript, and other ECMAScript
implementations for about 12 years now, of those about 9 professionally.
I have been doing Web development for about 14 years now (while my home
page certainly does not show it [yet], but I hope my solutions elsewhere
and my record here do). That includes Apache and IIS Web server
administration. (I am only mentioning this because I consider it
important for the maintainer of a technical FAQ to know their stuff well.)

- I have written several multi-purpose script libraries and published them
under the GNU General Public License. (Follow "Scripting" on my home page
or ask Google).

- I have been maintaining the ECMAScript Support Matrix for 3 years, which
is hopefully going to be a comprehensive comparison of the features of
existing ECMAScript implementations one day.

- I have never written any "Javascript" book ;-)

- I have been regularly contributing to technical Usenet newsgroups,
particularly de.comp.lang.javascript and this newsgroup, for about 6
years now (with a one-year pause in-between). I have made some minor
contributions to the de.comp.lang.javascript FAQ, but I have never
maintained a FAQ before.

- I consider myself a hacker[1], which is the main reason why I think we
need a good FAQ: (free) time is too precious to be wasted on solving old
problems; existing solutions should be able to be found quickly and
referred to more easily. They should be understandable by anyone willing
to learn without much asking further questions about them here.

[1] <http://www.catb.org/~esr/faqs/hacker-howto.html>

- I am born German, living and working in Switzerland since about 2
years. While my English has been rated quite good recently, when
implementing changes I might still rely on the better judgment of those
who speak it as native language.

- I have a full-time job and I am continuing my university-level studies in
computer science with distance learning, which means that I would do this
in what is left of my free time. I am going to reserve a time slot for
regular FAQ reviews on the weekends. I might be able to do little changes
in-between.

- I would maintain the FAQ under one condition: You would have to trust me
in the regard that after I have carefully considered all arguments
provided here, I would make the final decision what is or is not going to
be in the FAQ at a certain point (unless Jim objected to that; it is his
Web site, after all).

If you can accept that, just drop me a note, and I will be glad to take over
and to set things in motion again.
Regards,

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Aug 10 '08 #12

P: n/a
Thomas 'PointedEars' Lahn a écrit :
Jim Ley wrote:
>I do agree on the updates - do we have a new maintainer that I should
give access too?

We might have one.
Well, not you I hope for the sanity of FAQ readibiliy.
At that time, I actually considered supporting him in the task rather than
taking over, but I had much too little free time on my hands even for that.
If only it was true, at least clj would get rid of you, but it is not
true, not at all. You have *way* *too* much free time on your hands,
just take a look at the posting time of your boring posts here at clj
(not even looking at the de.* hierarchy which I suppose is full of your
silly posts : "This is not javascript, it is JavaScript." Pfff,
ridiculous little one)
- I would maintain the FAQ under one condition: You would have to trust me
in the regard that after I have carefully considered all arguments
provided here, I would make the final decision what is or is not going to
be in the FAQ at a certain point (unless Jim objected to that; it is his
Web site, after all).
Good lord, that is the *main* reason to *NOT* choose you, and there are
a lot more reasons to not to. For a start, You can't be trusted.
Trustable people doesn't consider themselves as superior from the
others. Which is obviously not the case with you.

--
laurent
Aug 10 '08 #13

P: n/a
On Aug 10, 6:01*am, Laurent vilday <mok...@mokhet.comwrote:
Thomas 'PointedEars' Lahn a écrit :
Jim Ley wrote:
>
Good lord, that is the *main* reason to *NOT* choose you, and there are
a lot more reasons to not to. For a start, You can't be trusted.
Trustable people doesn't consider themselves as superior from the
others. Which is obviously not the case with you.
It's not much of a position of authority, though it could potentially
be used to scare off/insult new users. I think if that were to happen,
it would be good reason to change the FAQ maintainer immediately. The
FAQ maintainer should be a model citizen on the group, not pointlessly
argumentative.

Whoever takes over ought to take the comments there under
consideration.
http://groups.google.com/group/comp....ff92cf482c94e0

I'm half tempted to volunteer, but I'm starting another project right
now. Its related to something Microsoft says is "designed to work in
standard mode out of this box." Something that "will take the web
experience beyond the page whether you are a web developer writing to
standards or a user.."

How about Lasse? or Bart Van der Donck? Whoever it is, should have
good knowledge of Ecma-262 r3 and Browsers and, as I said before, a
model citizen for the newsgroup (sans insults, arguing over minutiae
to miss the point, et c).

Garrett
>
--
laurent
Aug 10 '08 #14

P: n/a
In comp.lang.javascript message <48**************@PointedEars.de>, Sun,
10 Aug 2008 12:48:59, Thomas 'PointedEars' Lahn <Po*********@web.de>
posted:
>
Therefore, I am hereby volunteering for the job.
One such as yourself is entirely unfitted to the job. It requires a
reasonably normal human being.

--
(c) John Stockton, nr London UK. replyYYWW merlyn demon co uk Turnpike 6.05.
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm: about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Aug 10 '08 #15

P: n/a
In comp.lang.javascript message <2413112d-ea25-48f6-9895-2f9aa10f7b61@w3
9g2000prb.googlegroups.com>, Sun, 10 Aug 2008 10:45:21, dhtml
<dh**********@gmail.composted:
>Whoever takes over ought to take the comments there under
consideration.
http://groups.google.com/group/comp....ff92cf482c94e0

I see two approaches for a new maintainer :
Rework it completely from his own knowledge, and present that as a
draft for comment;
Take it as it is, and ask for new comment.

Since, for a year and a half, most then all of comment has been ignored,
it would take a weirdo masochist to work through the lot via Google or
FAQ**TRY; but it would be sufficient to be guided by what is now thought
important.
The FAQ Notes are anonymous and undated; and it is not clear whether
they are maintained. The only indication of authorship that I recall is
their being on the jibbering site, which falsely suggests Jim Ley
(though they are clearly not in his style of writing; and I do know who
wrote them).

IMHO, either the FAQ Notes should be taken over, fully, by the FAQ
maintainer (probably an unreasonable suggestion!); or the FAQ should be
re-worded to make it perfectly clear that the Notes are not maintained
by the FAQ system and so, as far as the group is concerned, have no more
authority as an expression of current collective thinking than the pages
of, for example, myself or Microsoft.

In any case, the Note pages should be given the name of who/what is
responsible and an appropriate date - as is the case for all worthwhile
documents.
The FAQ earlier was, and again is, very weak on Date and Time matters;
IMHO, the intermediate state should be restored or something better
provided. It is also weak on RegExp; the substring "regex" occurs only
once, in a link in Sec 4.16, and "Regular" in that sense also occurs
only in 4.16. It has nothing on sorting.

FAQ 4.30, lastModified : the facts need checking by someone with access
to or reliable memory of a large number of browsers of various ages. It
contains "though problems can occur if the browser returns only two
digits for the year" which *might* now be better replaced by "though
errors may occur with older browsers which return only two-digit years
or omit offset indication".

ECMA4 ought to add document.lastUploaded, being _EITHER_ a String or
Number representing the number of [milli]seconds from 1970.0 UTC or
other fixed epoch _OR_ a copy of the Last-Modified header; that would
make things much simpler. I think new Date(Last-Modified) will always
be correct. If there is no such header, the property should (choose and
define) either not exist or be respectively NaN or "".

--
(c) John Stockton, nr London UK. replyYYWW merlyn demon co uk Turnpike 6.05.
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm: about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Aug 11 '08 #16

This discussion thread is closed

Replies have been disabled for this discussion.