Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12517
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <1982352.3pIkI1WyPu@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Fri, 09 Mar 2012 04:05:42 +0100 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 8Bit |
| Subject | Re: Super basic newbie question |
| Newsgroups | comp.lang.javascript |
| References | <aaa3f536-d041-47fd-9c0c-2b158d5b82ee@x7g2000pbi.googlegroups.com> <4f58cb5b$0$6987$e4fe514c@news2.news.xs4all.nl> |
| Followup-To | comp.lang.javascript |
| MIME-Version | 1.0 |
| Lines | 65 |
| NNTP-Posting-Date | 09 Mar 2012 04:05:42 CET |
| NNTP-Posting-Host | 8a491295.newsspool1.arcor-online.net |
| X-Trace | DXC=1>9nTUKa3i_aAeROF2PWMQic==]BZ:af^4Fo<]lROoRQ<`=YMgDjhgRD^`i3[Q<Q2^DZm8W4\YJN\b@mF9jNikdUlYEA^Z8=X`P]0WcIb78[l^ |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:12517 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
Tom de Neef wrote:
> "Larry.Martell@gmail.com" […]
>> Just getting started in javascript. This is my very first script.
>>
>> I have a very simple web page with a text entry field:
>>
>> <input type="text" id='filterValue" size=20>
>>
>> In my javascript function I want to get each keystroke from that
>> field, and write it out. So I have:
>>
>> window.onload = function() {
>> document.getElementById("filterValue").onkeypress = function() {
>> var val = document.getElementById("filterValue").value;
>> document.write("<p>" + val + "</p>");
>> }
>> }
>
> I am a newby myself, so I may easily be corrected.
> Check out document.write.
Did you mean "remove"? "(To) check out" is colloquial for "(to) look into"
or "(to) retrieve" (with version control systems) instead.
> It will create a new execution context.
No, it will not. A new execution context can only be created with a
function and, in a browser environment, a new view (e.g., tab or window).
> Thus you loose everything you thought you had declared.
^^^^^
([to] _lose_ – lost – lost. "(to) loose" something means to untie something
instead.)
What you probably meant to say is that if document.write() is called after
the document has been loaded, and the output stream has been closed, it
opens a new output stream (as if by document.open(), see W3C DOM Level 2
HTML) and overwrites the existing document tree, which often causes the
previously existing global script execution context to be at least partially
deconstructed by the user agent. (There is no public standard to specify a
proper behavior, and it varies, which is why this should be avoided.)
In this case, the event listener that calls document.write() is being
added/defined after the window has been loaded (thanks to `window.onload'),
which often suggests that the document in the window has been loaded, too.
So the call to document.write() is bound to happen after the document has
been loaded.
The solution is to use other DOM manipulation methods instead. It may be
contained in nor referred to by the FAQ of this newsgroup, which one should
always consult before asking a question here.
> Also check 'this'. Within the onkeypress function you ought to be able to
> refer to the control that handled the event via .this.
Correct.
PointedEars
--
Sometimes, what you learn is wrong. If those wrong ideas are close to the
root of the knowledge tree you build on a particular subject, pruning the
bad branches can sometimes cause the whole tree to collapse.
-- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom@94.75.214.39>
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Super basic newbie question "Larry.Martell@gmail.com" <larry.martell@gmail.com> - 2012-03-08 06:51 -0800
Re: Super basic newbie question Martin Honnen <mahotrash@yahoo.de> - 2012-03-08 16:04 +0100
Re: Super basic newbie question "Larry.Martell@gmail.com" <larry.martell@gmail.com> - 2012-03-08 09:15 -0800
Re: Super basic newbie question Mike Duffy <never@you.mind.com> - 2012-03-09 01:01 +0000
Re: Super basic newbie question "Tom de Neef" <tdeneef@qolor.nl> - 2012-03-08 16:08 +0100
Re: Super basic newbie question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-03-09 04:05 +0100
Re: Super basic newbie question "Tom de Neef" <tdeneef@qolor.nl> - 2012-03-09 10:47 +0100
Re: Super basic newbie question SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-03-08 16:10 +0100
Re: Super basic newbie question "Larry.Martell@gmail.com" <larry.martell@gmail.com> - 2012-03-08 09:15 -0800
Re: Super basic newbie question Dr J R Stockton <reply1210@merlyn.demon.co.uk> - 2012-03-09 21:39 +0000
Re: Super basic newbie question SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-03-10 09:55 +0100
Re: Super basic newbie question Swifty <steve.j.swift@gmail.com> - 2012-03-10 18:19 +0000
Re: Super basic newbie question Tim Streater <timstreater@greenbee.net> - 2012-03-10 21:59 +0000
Re: Super basic newbie question Swifty <steve.j.swift@gmail.com> - 2012-03-12 09:58 +0000
Re: Super basic newbie question Tim Streater <timstreater@greenbee.net> - 2012-03-12 10:02 +0000
Re: Super basic newbie question Swifty <steve.j.swift@gmail.com> - 2012-03-12 10:57 +0000
Re: Super basic newbie question John G Harris <john@nospam.demon.co.uk> - 2012-03-12 15:39 +0000
Re: Super basic newbie question John G Harris <john@nospam.demon.co.uk> - 2012-03-12 15:37 +0000
Re: Super basic newbie question Swifty <steve.j.swift@gmail.com> - 2012-03-13 10:34 +0000
Re: Super basic newbie question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-03-13 10:12 -0600
Re: Super basic newbie question Tim Streater <timstreater@greenbee.net> - 2012-03-13 19:44 +0000
Re: Super basic newbie question Gene Wirchenko <genew@ocis.net> - 2012-03-13 19:50 -0700
Re: Super basic newbie question Gene Wirchenko <genew@ocis.net> - 2012-03-13 08:58 -0700
Re: Super basic newbie question SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-03-11 00:04 +0100
Re: Super basic newbie question Tim Streater <timstreater@greenbee.net> - 2012-03-10 23:16 +0000
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-12 16:41 -0700
Re: Super basic newbie question Tim Streater <timstreater@greenbee.net> - 2012-03-13 19:46 +0000
Re: Super basic newbie question Dr J R Stockton <reply1211@merlyn.demon.co.uk.not.invalid> - 2012-03-14 21:01 +0000
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-14 17:18 -0700
Re: Super basic newbie question John G Harris <john@nospam.demon.co.uk> - 2012-03-15 20:16 +0000
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-15 14:36 -0700
Re: Super basic newbie question Tim Streater <timstreater@greenbee.net> - 2012-03-15 23:41 +0000
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-15 16:49 -0700
Re: Super basic newbie question John G Harris <john@nospam.demon.co.uk> - 2012-03-16 16:55 +0000
Re: Super basic newbie question Tim Streater <timstreater@greenbee.net> - 2012-03-16 18:09 +0000
Re: Super basic newbie question Dr J R Stockton <reply1211@merlyn.demon.co.uk.not.invalid> - 2012-03-16 19:47 +0000
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-16 18:27 -0700
Re: Super basic newbie question Dr J R Stockton <reply1211@merlyn.demon.co.uk.not.invalid> - 2012-03-18 19:27 +0000
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-18 16:55 -0700
Re: Super basic newbie question Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2012-03-17 11:35 +0100
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-17 09:42 -0700
Re: Super basic newbie question Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2012-03-18 01:33 +0100
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-17 17:46 -0700
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-17 19:45 -0700
Re: Super basic newbie question Tim Streater <timstreater@greenbee.net> - 2012-03-15 10:00 +0000
Re: Super basic newbie question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-03-17 14:53 +0100
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-17 12:43 -0700
Re: Super basic newbie question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-03-17 23:39 +0100
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-17 15:54 -0700
Re: Super basic newbie question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-03-18 10:48 +0100
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-18 04:06 -0700
Re: Super basic newbie question Tim Streater <timstreater@greenbee.net> - 2012-03-18 13:52 +0000
Re: Super basic newbie question David Mark <dmark.cinsoft@gmail.com> - 2012-03-18 12:10 -0700
Re: Super basic newbie question Dr J R Stockton <reply1210@merlyn.demon.co.uk> - 2012-03-11 19:02 +0000
Re: Super basic newbie question "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-03-08 17:17 +0200
Re: Super basic newbie question "Larry.Martell@gmail.com" <larry.martell@gmail.com> - 2012-03-08 09:17 -0800
Re: Super basic newbie question Gene Wirchenko <genew@ocis.net> - 2012-03-08 08:44 -0800
Re: Super basic newbie question "Larry.Martell@gmail.com" <larry.martell@gmail.com> - 2012-03-08 09:24 -0800
Re: Super basic newbie question Denis McMahon <denismfmcmahon@gmail.com> - 2012-03-08 17:03 +0000
csiph-web