Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #21865 > unrolled thread
| Started by | "Robert Crandal" <noreply2me@yahoo.com> |
|---|---|
| First post | 2013-11-03 01:36 -0700 |
| Last post | 2013-11-04 01:15 +0100 |
| Articles | 17 — 7 participants |
Back to article view | Back to comp.lang.javascript
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
| From | "Robert Crandal" <noreply2me@yahoo.com> |
|---|---|
| Date | 2013-11-03 01:36 -0700 |
| Subject | Broken example on w3schools.com? |
| Message-ID | <tLadnQ8umMSOluvPnZ2dnUVZ5rCdnZ2d@giganews.com> |
Using the latest version of Chrome, I visited the following link that has an example of code for "getElementsByTagName()": http://www.w3schools.com/jsref/met_doc_getelementsbytagname.asp Go to the bottom of the page and push the "Try it yourself" button. Now, try pushing the "How many input elements?" button. Why is the Javascript alert not showing? Is something wrong with the source code on the left pane?
[toc] | [next] | [standalone]
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Date | 2013-11-03 10:59 +0200 |
| Message-ID | <l55391$v1g$1@dont-email.me> |
| In reply to | #21865 |
2013-11-03 10:36, Robert Crandal wrote: > Using the latest version of Chrome, I visited the following link that > has an example of code for "getElementsByTagName()": > > http://www.w3schools.com/jsref/met_doc_getelementsbytagname.asp Consider using reasonably reliable references instead, such as https://developer.mozilla.org/en-US/docs/Web >Is something wrong with the source > code on the left pane? Possibly. But that's really not important. Avoid w3schools, unless you are very experienced and you have a mission of demonstrating how bad it is, possibly contributing to making http://w3fools.com even more convincing about that. -- Yucca, http://www.cs.tut.fi/~jkorpela/
[toc] | [prev] | [next] | [standalone]
| From | "Robert Crandal" <noreply2me@yahoo.com> |
|---|---|
| Date | 2013-11-03 02:27 -0700 |
| Message-ID | <GuOdnWxNpJeLiuvPnZ2dnUVZ5rKdnZ2d@giganews.com> |
| In reply to | #21866 |
"Jukka K. Korpela" <jkorpela@cs.tut.fi> wrote: >> 2013-11-03 10:36, Robert Crandal wrote: >> Is something wrong with the source >> code on the left pane? > > Possibly. But that's really not important. Avoid w3schools, unless you are > very experienced and you have a mission of demonstrating how bad it is, > possibly contributing to making http://w3fools.com even more convincing > about that. > Thanks for the resources, but I'm still curious why the w3schools.com source code doesn't work on Chrome. This is the first time that I've seen a w3school example NOT work. It looked like valid code to me. I tried adding closing </input> tags where appropriate, but still nothing.
[toc] | [prev] | [next] | [standalone]
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2013-11-03 10:53 +0100 |
| Message-ID | <52761d32$0$6639$9b4e6d93@newsspool2.arcor-online.net> |
| In reply to | #21865 |
Robert Crandal wrote: > Using the latest version of Chrome, I visited the following link that > has an example of code for "getElementsByTagName()": > > http://www.w3schools.com/jsref/met_doc_getelementsbytagname.asp > > Go to the bottom of the page and push the "Try it yourself" button. > Now, try pushing the "How many input elements?" button. Why is > the Javascript alert not showing? Is something wrong with the source > code on the left pane? When I press the button on above page a new tab with http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsbytagname is opened and there I can press the button "How many input elements?" on the right and it alerts "4". Tested with Chrome Version 30.0.1599.101 m.
[toc] | [prev] | [next] | [standalone]
| From | "Robert Crandal" <noreply2me@yahoo.com> |
|---|---|
| Date | 2013-11-03 03:46 -0700 |
| Message-ID | <wrednc2y0uIAtOvPnZ2dnUVZ5v-dnZ2d@giganews.com> |
| In reply to | #21868 |
"Martin Honnen" <mahotrash@yahoo.de> wrote: > > When I press the button on above page a new tab with > http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsbytagname > is opened and there I can press the button "How many input elements?" on > the right and it alerts "4". > > Tested with Chrome Version 30.0.1599.101 m. Yes, my version of Chrome is "Version 30.0.1599.101 m". Nothing happens when I press the "How many input elements?" button. But, the code does work in that latest Firefox. Hmmm, odd that it doesn't work in my Chrome, but it works on yours, and we have the same Chrome version.
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2013-11-03 10:53 +0000 |
| Message-ID | <031120131053367515%timstreater@greenbee.net> |
| In reply to | #21869 |
In article <wrednc2y0uIAtOvPnZ2dnUVZ5v-dnZ2d@giganews.com>, Robert Crandal <noreply2me@yahoo.com> wrote: > "Martin Honnen" <mahotrash@yahoo.de> wrote: > > > > When I press the button on above page a new tab with > > > > http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsby > > tagname > > is opened and there I can press the button "How many input elements?" on > > the right and it alerts "4". > > > > Tested with Chrome Version 30.0.1599.101 m. > > Yes, my version of Chrome is "Version 30.0.1599.101 m". Nothing > happens when I press the "How many input elements?" button. > But, the code does work in that latest Firefox. > > Hmmm, odd that it doesn't work in my Chrome, but it works on yours, > and we have the same Chrome version. Worked for me on Safari 6.1. -- Tim "That excessive bail ought not to be required, nor excessive fines imposed, nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
[toc] | [prev] | [next] | [standalone]
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2013-11-03 12:14 +0100 |
| Message-ID | <52763025$0$6641$9b4e6d93@newsspool2.arcor-online.net> |
| In reply to | #21870 |
Tim Streater wrote: > In article <wrednc2y0uIAtOvPnZ2dnUVZ5v-dnZ2d@giganews.com>, Robert > Crandal <noreply2me@yahoo.com> wrote: > >> "Martin Honnen" <mahotrash@yahoo.de> wrote: >> > >> > When I press the button on above page a new tab with > >> > >> http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsby >> >> > tagname > is opened and there I can press the button "How many input >> elements?" on > the right and it alerts "4". >> > >> > Tested with Chrome Version 30.0.1599.101 m. >> >> Yes, my version of Chrome is "Version 30.0.1599.101 m". Nothing >> happens when I press the "How many input elements?" button. Press F12 to open the developer tools and check whether Chrome shows some error message in the console.
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2013-11-03 11:29 +0000 |
| Message-ID | <031120131129196107%timstreater@greenbee.net> |
| In reply to | #21871 |
In article <52763025$0$6641$9b4e6d93@newsspool2.arcor-online.net>, Martin Honnen <mahotrash@yahoo.de> wrote: > Tim Streater wrote: > > In article <wrednc2y0uIAtOvPnZ2dnUVZ5v-dnZ2d@giganews.com>, Robert > > Crandal <noreply2me@yahoo.com> wrote: > > > >> "Martin Honnen" <mahotrash@yahoo.de> wrote: > >> > > >> > When I press the button on above page a new tab with > > >> > > >> > >> http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsb > >> y > >> > >> > tagname > is opened and there I can press the button "How many input > >> elements?" on > the right and it alerts "4". > >> > > >> > Tested with Chrome Version 30.0.1599.101 m. > >> > >> Yes, my version of Chrome is "Version 30.0.1599.101 m". Nothing > >> happens when I press the "How many input elements?" button. > > Press F12 to open the developer tools and check whether Chrome shows > some error message in the console. Works here on Version 30.0.1599.69. F12 brings up Dashboard here. -- Tim "That excessive bail ought not to be required, nor excessive fines imposed, nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
[toc] | [prev] | [next] | [standalone]
| From | "Robert Crandal" <noreply2me@yahoo.com> |
|---|---|
| Date | 2013-11-03 12:28 -0700 |
| Message-ID | <lo2dncUZ99ZUPuvPnZ2dnUVZ5sudnZ2d@giganews.com> |
| In reply to | #21871 |
"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".
The only extension that I have is Google Docs. I tried disabling that,
but it had no effect. I'm not sure what's going on here. Last night
I was using the "Inspect element". I don't think I pressed any buttons,
as I was only peeking at CSS styles and etcetera.
Any ideas?
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-11-03 20:49 +0100 |
| Message-ID | <4130220.symPJ1cTr9@PointedEars.de> |
| In reply to | #21876 |
Robert Crandal wrote: > "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". I do not get that message … > Then, when I tried pressing the input button there is a message in the > console that says: > "Uncaught SyntaxError: getElements is not defined". … or this one. > The only extension that I have is Google Docs. I tried disabling that, > but it had no effect. I'm not sure what's going on here. Last night > I was using the "Inspect element". I don't think I pressed any buttons, > as I was only peeking at CSS styles and etcetera. > > Any ideas? Hold down the “Reload” button and select “Empty Cache and Hard Reload” from the drop-down menu. Or press Ctrl/Cmd+Shift+Delete and “[x] empty the cache” from “the beginning of time”, and click “Reload”. If that does not help, your problem very likely is beyond the scope of this newsgroup. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | "Robert Crandal" <noreply2me@yahoo.com> |
|---|---|
| Date | 2013-11-03 14:29 -0700 |
| Message-ID | <RJWdnXA-UcPbXevPnZ2dnUVZ5gmdnZ2d@giganews.com> |
| In reply to | #21877 |
"Thomas 'PointedEars' Lahn" <PointedEars@web.de> wrote: > > Hold down the "Reload" button and select "Empty Cache and Hard Reload" > from > the drop-down menu. Or press Ctrl/Cmd+Shift+Delete and "[x] empty the > cache" from "the beginning of time", and click "Reload". > Doh, it still didn't work. Thanks for the help anyways. 8)
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2013-11-03 21:21 +0000 |
| Message-ID | <0.14de356e0b8944a153ab.20131103212144GMT.87sivdji53.fsf@bsb.me.uk> |
| In reply to | #21876 |
"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. 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. 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. Looks like more junk from a junk-filled site. <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | "Robert Crandal" <noreply2me@yahoo.com> |
|---|---|
| Date | 2013-11-03 15:10 -0700 |
| Message-ID | <HeudnYzxRplwVOvPnZ2dnUVZ5tOdnZ2d@giganews.com> |
| In reply to | #21879 |
"Ben Bacarisse" <ben.usenet@bsb.me.uk> wrote: > Why these are there is a mystery. 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. > Yup, this was the problem. I went to the above URL and clicked "View page source" in my Chrome browser. I then highlighted all the HTML code and copied and pasted it into Notepad. You will see hidden characters in the Notepad document that look like little empty squares. Just delete those extra characters, then save the code in a new HTML file and now it works! 8)
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-11-03 23:32 +0100 |
| Message-ID | <3249832.hYQsY692ZD@PointedEars.de> |
| In reply to | #21879 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-11-03 13:26 +0100 |
| Message-ID | <153744960.ZLAmpRSkbQ@PointedEars.de> |
| In reply to | #21869 |
Robert Crandal wrote: > "Martin Honnen" <mahotrash@yahoo.de> wrote: >> When I press the button on above page a new tab with >> http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsbytagname >> is opened and there I can press the button "How many input elements?" on >> the right and it alerts "4". >> >> Tested with Chrome Version 30.0.1599.101 m. > > Yes, my version of Chrome is "Version 30.0.1599.101 m". Nothing > happens when I press the "How many input elements?" button. > But, the code does work in that latest Firefox. > > Hmmm, odd that it doesn't work in my Chrome, but it works on yours, > and we have the same Chrome version. Although the example code is poorly written, as can be expected on w3schools.com, I can see “4” in navigator.userAgent === "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36" (Chromium “Version 30.0.1599.101 Debian jessie/sid (227552)”) and navigator.userAgent === "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.39 Safari/537.36" (Chrome “Version 31.0.1650.39 beta”). It is possible that some extension prevents the alert window from showing, or that it is displayed in the background. Try what Martin suggested, then try disabling extensions. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Dr.Kral@nyc.rr.com |
|---|---|
| Date | 2013-11-03 16:35 -0500 |
| Message-ID | <f9gd795kujrgs9s99688okj96kagogiii6@4ax.com> |
| In reply to | #21869 |
On Sun, 3 Nov 2013 03:46:53 -0700, "Robert Crandal" <noreply2me@yahoo.com> wrote in <wrednc2y0uIAtOvPnZ2dnUVZ5v-dnZ2d@giganews.com>: >"Martin Honnen" <mahotrash@yahoo.de> wrote: >> >> When I press the button on above page a new tab with >> http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsbytagname >> is opened and there I can press the button "How many input elements?" on >> the right and it alerts "4". >> >> Tested with Chrome Version 30.0.1599.101 m. > >Yes, my version of Chrome is "Version 30.0.1599.101 m". Nothing >happens when I press the "How many input elements?" button. >But, the code does work in that latest Firefox. > >Hmmm, odd that it doesn't work in my Chrome, but it works on yours, >and we have the same Chrome version. > > Have you disabled JS?? There is a toggle to the left of the address bar -- does it show a red dot? That indicates disabled.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-11-04 01:15 +0100 |
| Message-ID | <3183586.71oeareOng@PointedEars.de> |
| In reply to | #21881 |
Dr.Kral@nyc.rr.com wrote: > […] "Robert Crandal" […] wrote […]: >> Hmmm, odd that it doesn't work in my Chrome, but it works on yours, >> and we have the same Chrome version. > > Have you disabled JS?? You are a bit late to the party. > There is a toggle to the left of the address bar -- There is not, at least not in a vanilla Chrome/Chromium setup. > does it show a red dot? That indicates disabled. Maybe in your browser, perhaps by extension. Please get a real name. And skip the attribution novel next time. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web