Select text within a div tag by clicking on content of div tag?

Discussion in 'Javascript' started by M Wells, Oct 6, 2004.

  1. M Wells

    M Wells Guest

    Hi All,

    Wondering if anyone can tell me if it's possible to have Javascript
    select the contents of a div tag with a unique id by clicking
    somewhere in the contents of that div tag?

    I want to make it as easy as possible for users to copy the contents
    of the div tag for pasting in another page. So, instead of having them
    use the mouse to drag the selection, which can sometimes be annoying,
    I'd like to have them click anywhere within the div tag and have the
    text automatically selected, and then they can simply right click and
    select 'Copy'.

    If this is possible, can anyone give me some advice on how to achieve
    it?

    As an alternative, if a div tag won't respond to an onClick event
    itself, would it be possible to select the contents of that div tag
    (assume, for eg, that it has the unique id of "Copy1") by clicking on
    a button?

    Any help with this would be much appreciated!

    Much warmth,

    Murray
    M Wells, Oct 6, 2004
    #1
    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. Lily
    Replies:
    1
    Views:
    1,478
    Teemu Keiski
    Dec 23, 2003
  2. shruds
    Replies:
    1
    Views:
    744
    John C. Bollinger
    Jan 27, 2006
  3. Eqbal Z
    Replies:
    6
    Views:
    174
    Eqbal Z
    Aug 27, 2003
  4. visu
    Replies:
    4
    Views:
    277
  5. Tom Y
    Replies:
    1
    Views:
    212
    Elegie
    Jul 12, 2011
Loading...

Share This Page