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

Discussion in 'Javascript' started by cron, Oct 11, 2011.

  1. cron

    cron Guest

    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>
     
    cron, Oct 11, 2011
    #1
    1. Advertising

  2. 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
     
    Thomas 'PointedEars' Lahn, Oct 11, 2011
    #2
    1. Advertising

  3. 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-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
     
    Antony Scriven, Oct 12, 2011
    #3
  4. 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
     
    John G Harris, Oct 12, 2011
    #4
  5. 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.)
     
    Thomas 'PointedEars' Lahn, Oct 12, 2011
    #5
  6. 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.)
     
    Thomas 'PointedEars' Lahn, Oct 12, 2011
    #6
  7. 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.)
     
    Thomas 'PointedEars' Lahn, Oct 12, 2011
    #7
  8. 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
     
    John G Harris, Oct 13, 2011
    #8
  9. 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
     
    Thomas 'PointedEars' Lahn, Oct 13, 2011
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zoe Hart
    Replies:
    1
    Views:
    3,737
    Craig Deelsnyder
    Jan 7, 2004
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,180
    David Schwartz
    Dec 9, 2003
  3. Noel Dolan
    Replies:
    0
    Views:
    261
    Noel Dolan
    Jul 18, 2004
  4. Gregor Kofler
    Replies:
    9
    Views:
    354
    Gregor Kofler
    Oct 8, 2009
  5. Bitswapper
    Replies:
    5
    Views:
    174
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page