Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #21883

Re: Broken example on w3schools.com?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.datemas.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <3249832.hYQsY692ZD@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Organization PointedEars Software (PES)
Date Sun, 03 Nov 2013 23:32:02 +0100
User-Agent KNode/4.10.5
Content-Transfer-Encoding 8Bit
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Subject Re: Broken example on w3schools.com?
Newsgroups comp.lang.javascript
References <tLadnQ8umMSOluvPnZ2dnUVZ5rCdnZ2d@giganews.com> <52761d32$0$6639$9b4e6d93@newsspool2.arcor-online.net> <wrednc2y0uIAtOvPnZ2dnUVZ5v-dnZ2d@giganews.com> <031120131053367515%timstreater@greenbee.net> <52763025$0$6641$9b4e6d93@newsspool2.arcor-online.net> <lo2dncUZ99ZUPuvPnZ2dnUVZ5sudnZ2d@giganews.com> <0.14de356e0b8944a153ab.20131103212144GMT.87sivdji53.fsf@bsb.me.uk>
MIME-Version 1.0
Lines 81
NNTP-Posting-Date 03 Nov 2013 23:32:12 CET
NNTP-Posting-Host 2c1a1429.newsspool1.arcor-online.net
X-Trace DXC=o]FcB@LFjD5L2C_`koXfC5ic==]BZ:af>4Fo<]lROoR1nkgeX?EC@@0PmZQ?n;CHJ5DZm8W4\YJN<YUVHKH;GI^7b`YH7>Ffd\8i^;`X6S4RJ1
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:21883

Show key headers only | View raw


Ben Bacarisse wrote:

> "Robert Crandal" <noreply2me@yahoo.com> writes:
>> "Martin Honnen" <mahotrash@yahoo.de> wrote:
>>> Press F12 to open the developer tools and check whether Chrome shows
>>> some error message in the console.
>>
>> Okay, I pressed F12.  The first message I saw was:
>>        "Uncaught SyntaxError: Unexpected token ILLEGAL".
>>
>> Then, when I tried pressing the input button there is a message in the
>> console that says:
>>       "Uncaught SyntaxError: getElements is not defined".
> 
> I get similar errors using Gnome's browser (stupidly called Web).  The
> problem is some erroneous characters (hex A0) in the script element.

The characters themselves are not erroneous; “White space characters may 
occur between any two tokens and at the start or end of input” in 
ECMAScript, and they are defined in §7.2 as

| WhiteSpace ::
|  <TAB>
|  <VT>
|  <FF>
|  <SP>
|  <NBSP>
|  <BOM>
|  <USP>

Very likely the actual problem here is that the white-space characters are 
not properly encoded, or rather, as you pointed out, that a proper character 
encoding for the source code has not been declared.  

This can be tested: If you write code containing NO-BREAK SPACE outside of 
string literals in the Chrome Dev Console, V8 would execute the code without 
syntax error, and if you encodeURIComponent() it the result will contain 
“%C2%A0” (so the NO-BREAK SPACE is not converted to SPACE before execution).

> These result in, first, a syntax error and later, when the button is
> pressed, an undefined function (getElements).
> 
> Why these are there is a mystery.

I got bitten by those when I copy-pasted space-indented code from postings 
viewed in my newsreader, KNode.  Apparently my KNode uses NO-BREAK SPACE in 
order to prevent the line-break at this position.  Eclipse editors show 
these as syntax error (JSDT even though it per ECMAScript they are not), but 
I still would prefer KNode to copy those characters as SPACE to the 
clipboard.

> The URL in question is
> 
> http://www.w3schools.com/jsref/tryjsref_doc_getelementsbytagname.htm
> 
> which is sent without any indication of the character encoding.  Hex A0
> are, most likely, non-breaking spaces encoding in Windows-1252.  If I
> force my browser to see the page as Windows-1252, it all works.

Good catch.  The site is relying on that with a missing declaration of 
character encoding (neither in the HTTP header nor in the document) the 
content will be considered ISO-8859-1/Windows-1252-encoded as specified by 
HTTP/1.1.  However, it is equally possible that per the document 
specification (or whim of the developers) it is considered UTF-8-encoded 
first instead, and then the octet sequence A0 alone does _not_ encode U+00A0 
NO-BREAK SPACE; that character would have to be encoded as C2 A0 instead.

The encoding error is made visible with “�”s (U+FFFD REPLACEMENT CHARACTER) 
in the “Network” tab of Chrome Dev Tools when you select the request for the 
HTML document and then the “Response” sub-tab.  However, my Chromium and 
Chrome for Linux ignore that encoding error.
 
> Looks like more junk from a junk-filled site.

ACK.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Broken example on w3schools.com? "Robert Crandal" <noreply2me@yahoo.com> - 2013-11-03 01:36 -0700
  Re: Broken example on w3schools.com? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-11-03 10:59 +0200
    Re: Broken example on w3schools.com? "Robert Crandal" <noreply2me@yahoo.com> - 2013-11-03 02:27 -0700
  Re: Broken example on w3schools.com? Martin Honnen <mahotrash@yahoo.de> - 2013-11-03 10:53 +0100
    Re: Broken example on w3schools.com? "Robert Crandal" <noreply2me@yahoo.com> - 2013-11-03 03:46 -0700
      Re: Broken example on w3schools.com? Tim Streater <timstreater@greenbee.net> - 2013-11-03 10:53 +0000
        Re: Broken example on w3schools.com? Martin Honnen <mahotrash@yahoo.de> - 2013-11-03 12:14 +0100
          Re: Broken example on w3schools.com? Tim Streater <timstreater@greenbee.net> - 2013-11-03 11:29 +0000
          Re: Broken example on w3schools.com? "Robert Crandal" <noreply2me@yahoo.com> - 2013-11-03 12:28 -0700
            Re: Broken example on w3schools.com? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-03 20:49 +0100
              Re: Broken example on w3schools.com? "Robert Crandal" <noreply2me@yahoo.com> - 2013-11-03 14:29 -0700
            Re: Broken example on w3schools.com? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-03 21:21 +0000
              Re: Broken example on w3schools.com? "Robert Crandal" <noreply2me@yahoo.com> - 2013-11-03 15:10 -0700
              Re: Broken example on w3schools.com? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-03 23:32 +0100
      Re: Broken example on w3schools.com? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-03 13:26 +0100
      Re: Broken example on w3schools.com? Dr.Kral@nyc.rr.com - 2013-11-03 16:35 -0500
        Re: Broken example on w3schools.com? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-04 01:15 +0100

csiph-web