Jump to content
Sign in to follow this  
banzemanga

How do i partially select text on a text(field/area)?

Recommended Posts

Well, in the DOM standard to select the text we use the .select() function. But the problem with this function is that it selects the entire text but i only want to make it select a portion.There is also the .setSelectionRange(start, end) but this is only for mozilla browsers including firefox. In other words, browsers like IE and Opera doesn't support it.To make it work in a IE browser, we need to create an activeX selection object, which has its own function.What i am wondering if there is any way to do it using DOM functions so that i don't have to write a function for each browser.What i have in mind is to send key codes to the value of the text container. For example, set the value of the textfield as hello + shift + left so that it will have hello with the letter o selected.Is is possible? And how do i send hey codes to the textfield value including things like press shift then left and then relesase shift?Thanks.

Share this post


Link to post
Share on other sites

There is unfortunately no one fully cross-browser method for selecting text at this time.I do not quite understand your second question.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...