SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting selected text

    Is there any way to find out what text a user has highlighted in a textbox?

    that can be done in Gecko aswell
    Last edited by Wilco; Jan 9, 2003 at 13:00.
    Wilco

  2. #2
    SitePoint Evangelist compwizard's Avatar
    Join Date
    May 2002
    Location
    United States
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Compwizard
    "There are 10 kinds of people in this world -- those who know binary, and those who don't."

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    northern Maine
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gecko stores selection offsets in a textarea and text input with the selectionStart and selectionEnd properties:

    HTMLTextAreaElement.prototype.__defineGetter__('selection', function () { return this.value.substring(this.selectionStart, this.selectionEnd) });

    Now every textarea has a read-only "selection" property which retrieves the selected text.
    Jason - Contact Me
    Supermoderator @ CodingForums


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •