Jump to content

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


banzemanga

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.

Link to comment
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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...