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


C

cron

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>
 
Ad

Advertisements

T

Thomas 'PointedEars' Lahn

cron said:
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
 
A

Antony Scriven

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.
The post displays just fine in my Thunderbird.

Cool. I still think the OP should properly wrap long lines
though.
Its as real as PointedEars.

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

http://www.catb.org/~esr/faqs/smart-questions.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
 
J

John G Harris

cron wrote:

- 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
 
T

Thomas 'PointedEars' Lahn

John said:
<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
 
T

Thomas 'PointedEars' Lahn

John said:
<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
 
Ad

Advertisements

T

Thomas 'PointedEars' Lahn

John said:
<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
 
J

John G Harris

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
 
Ad

Advertisements

T

Thomas 'PointedEars' Lahn

John said:
... 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top