Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > JS - prevent keypress bubbling to child with listener on parent?

Reply
Thread Tools

JS - prevent keypress bubbling to child with listener on parent?

 
 
cron
Guest
Posts: n/a
 
      10-11-2011
Is there any way to prevent bubbling to the child div in the setup below? Ibasically need to occasionally disallow return breaks and other charactersbut have the body function as a normal text editor otherwise. (in other words, adding contentEditable=true to child divs will not do)
Thanks in advance!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function checkKey(event){
if (event.keyCode === 13){
return(false)
}
return(true)
}
</script>
</head>

<body contentEditable="true" onkeydown="return(checkKey)">
<div>test 1</div>
<div>test 2</div>
<div>test 3</div>
</body>
</html>
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-11-2011
cron wrote:

> Is there any way to prevent bubbling to the child div in the setup below?


(Don't ask Yes-or-No questions unless you want a Yes-or-No answer.)

No, as it does not happen in the first place. Event bubbling is the second
phase of event propagation in which events are propagated to a target's
ancestors (*upwards* in the document tree, hence *bubbling*).

Please

- Fix your posting agent. Lines should not exceed 78 characters when
displayed as they are.

- Get a real name. This is Usenet, not some Web forum.

- RTFM.

<http://www.catb.org/~esr/faqs/smart-questions.html> (observe the key word,
FAQ, in there)


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
 
Reply With Quote
 
 
 
 
Antony Scriven
Guest
Posts: n/a
 
      10-12-2011
On Oct 12, 12:42 am, Andrew Poulos wrote:

> On 12/10/2011 4:48 AM, Thomas 'PointedEars' Lahn wrote:
>
> > cron wrote:

>
> > > Is there any way to prevent bubbling to the child div
> > > in the setup below?

>
> > (Don't ask Yes-or-No questions unless you want
> > a Yes-or-No answer.)

>
> Of course no one could possibly suspect that the OP would
> what to know how if the answer was "yes".


Well, I thought the following paragraph did usefully answer
the question.

> > No, as it does not happen in the first place. Event
> > bubbling is the second phase of event propagation in
> > which events are propagated to a target's ancestors
> > (*upwards* in the document tree, hence *bubbling*).

>
> > Please

>
> > - Fix your posting agent. Lines should not exceed 78
> > characters when displayed as they are.

>
> The post displays just fine in my Thunderbird.


Cool. I still think the OP should properly wrap long lines
though.

> > - Get a real name. This is Usenet, not some Web forum.

>
> Its as real as PointedEars.


Right, but 'Thomas Lahn' looks pretty real to me. Which is
all rather beside the point.

> > - RTFM.

>
> > <http://www.catb.org/~esr/faqs/smart-questions.html>
> > (observe the key word, > > FAQ, in there)

>
> And for you PE
> <http://www.catb.org/~esr/faqs/smart-questions.html#id479916>


http://www.catb.org/~esr/faqs/smart-...s.html#answers

I don't think there's much wrong with Thomas's tone *in this
instance* . On the other hand there's plenty of useful
advice for the OP and little to criticise if you're going to
use 'How To Ask Questions The Smart Way' as your reference
for Usenet etiquette. --Antony
 
Reply With Quote
 
John G Harris
Guest
Posts: n/a
 
      10-12-2011
On Tue, 11 Oct 2011 at 19:48:31, in comp.lang.javascript, Thomas
'PointedEars' Lahn wrote:
>cron wrote:


<snip>
>- Fix your posting agent. Lines should not exceed 78 characters when
> displayed as they are.

<snip>

According to the copy of cron's article exported from my news agent, the
raw text of the article is limited throughout to 72 characters maximum
on each line.

Could it be that your

User-Agent: KNode/4.4.11

is having trouble displaying

Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

John
--
John Harris
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-12-2011
John G Harris wrote:

> On Tue, 11 Oct 2011 at 19:48:31, in comp.lang.javascript, Thomas
> 'PointedEars' Lahn wrote:
>> cron wrote:

>
> <snip>
>>- Fix your posting agent. Lines should not exceed 78 characters when
>> displayed as they are.

> <snip>
>
> According to the copy of cron's article exported from my news agent, the
> raw text of the article is limited throughout to 72 characters maximum
> on each line.
>
> Could it be that your
>
> User-Agent: KNode/4.4.11
>
> is having trouble displaying
>
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable


No, the content of a line that ends with `=' in the quoted-printable
*transfer* *encoding* is considered to be continued on the next line:

<http://tools.ietf.org/html/rfc2045#page-19>
(simpler explanation in <http://en.wikipedia.org/wiki/Quoted-printable>)

Therefore, even though line 1 of the message body of the posting is only
72 characters long, the decoded line is actually 284 characters long (not
counting the trailing CR+LF).


HTH

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-12-2011
John G Harris wrote:

> On Tue, 11 Oct 2011 at 19:48:31, in comp.lang.javascript, Thomas
> 'PointedEars' Lahn wrote:
>> cron wrote:

>
> <snip>
>>- Fix your posting agent. Lines should not exceed 78 characters when
>> displayed as they are.

> <snip>
>
> According to the copy of cron's article exported from my news agent, the
> raw text of the article is limited throughout to 72 characters maximum
> on each line.
>
> Could it be that your
>
> User-Agent: KNode/4.4.11
>
> is having trouble displaying
>
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable


No, the content of a line that ends with `=' in the quoted-printable
*transfer* *encoding* is considered to be continued on the next line:

<http://tools.ietf.org/html/rfc2045#page-19>
(simpler explanation in <http://en.wikipedia.org/wiki/Quoted-printable>)

Therefore, even though line 1 of the message body of the posting is only
75 characters long, the decoded line is actually 284 characters long (not
counting the trailing CR+LF).


HTH

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-12-2011
John G Harris wrote:

> On Tue, 11 Oct 2011 at 19:48:31, in comp.lang.javascript, Thomas
> 'PointedEars' Lahn wrote:
>> cron wrote:

>
> <snip>
>>- Fix your posting agent. Lines should not exceed 78 characters when
>> displayed as they are.

> <snip>
>
> According to the copy of cron's article exported from my news agent, the
> raw text of the article is limited throughout to 72 characters maximum
> on each line.
>
> Could it be that your
>
> User-Agent: KNode/4.4.11
>
> is having trouble displaying
>
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable


No, the content of a line that ends with `=' in the quoted-printable
*transfer* *encoding* is considered to be continued on the next line:

<http://tools.ietf.org/html/rfc2045#page-19>
(simpler explanation in <http://en.wikipedia.org/wiki/Quoted-printable>)

Therefore, even though line 1 of the message body of the posting is only
76 characters long, the decoded line is actually 284 characters long (not
counting the trailing CR+LF).


HTH

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
 
Reply With Quote
 
John G Harris
Guest
Posts: n/a
 
      10-13-2011
On Wed, 12 Oct 2011 at 21:31:55, in comp.lang.javascript, Thomas
'PointedEars' Lahn wrote:
>John G Harris wrote:
>
>> On Tue, 11 Oct 2011 at 19:48:31, in comp.lang.javascript, Thomas
>> 'PointedEars' Lahn wrote:
>>> cron wrote:

>>
>> <snip>
>>>- Fix your posting agent. Lines should not exceed 78 characters when
>>> displayed as they are.

>> <snip>
>>
>> According to the copy of cron's article exported from my news agent, the
>> raw text of the article is limited throughout to 72 characters maximum
>> on each line.
>>
>> Could it be that your
>>
>> User-Agent: KNode/4.4.11
>>
>> is having trouble displaying
>>
>> Content-Type: text/plain; charset=ISO-8859-1
>> Content-Transfer-Encoding: quoted-printable

>
>No, the content of a line that ends with `=' in the quoted-printable
>*transfer* *encoding* is considered to be continued on the next line:
>
><http://tools.ietf.org/html/rfc2045#page-19>
>(simpler explanation in <http://en.wikipedia.org/wiki/Quoted-printable>)
>
>Therefore, even though line 1 of the message body of the posting is only
>76 characters long, the decoded line is actually 284 characters long (not
>counting the trailing CR+LF).


.... which a sensible mail/news program, such as mine or Andrew's,
displays sensibly.

Or would you rather blame Google for making its usual mess of things?

John
--
John Harris
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-13-2011
John G Harris wrote:

> Thomas 'PointedEars' Lahn wrote:
>> No, the content of a line that ends with `=' in the quoted-printable
>> *transfer* *encoding* is considered to be continued on the next line:
>>
>> <http://tools.ietf.org/html/rfc2045#page-19>
>> (simpler explanation in <http://en.wikipedia.org/wiki/Quoted-printable>)
>>
>> Therefore, even though line 1 of the message body of the posting is only
>> 76 characters long, the decoded line is actually 284 characters long (not
>> counting the trailing CR+LF).

>
> ... which a sensible mail/news program, such as mine or Andrew's,
> displays sensibly.


"No true Scotsman" fallacy. (JFTR: KNode word-wraps the message at the pane
edges. One could argue as well that no sensible mail/news program would
generate attribution novels that make for a two-line attribution, so yours
would disqualify. Neither argument would change the fact that the message
is too wide as the decoded maximum line length is too high for proper
reading *without* assistive technology.)

> Or would you rather blame Google for making its usual mess of things?


A posting agent should assist the user in posting messages with lines that
are of appropriate length, indeed. For example, KNode and several other
programs can word-wrap text at a user-defined column (set to 76 here, which
is the default) while typing.


F'up2 poster

PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross browser handling special chars with keypress/keyup listener Gregor Kofler Javascript 9 10-08-2009 04:48 PM
How to prevent the popup child page redirect to login page? ABC ASP .Net 0 12-12-2005 08:40 AM
How to prevent a function in base class being overloaded from child class modemer C++ 20 03-22-2005 04:51 PM
JScript Event Listener from Child Window - PLEASE HELP!!! keith Javascript 2 03-18-2005 12:35 AM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57