question relating to document.selection

C

c.anandkumar

Hi
How do I figure out if a selection in a document is in a particular
control?
I have a TEXTAREA in which a user can type in some text, select some
text and 'apply' tags around it clicking a button. I am using
document.selection.createRange() to create a textRange object and then
modify its text property to suit the action. But the problem is I want
to limit this action to a few "INPUT type=text" and TEXTAREA controls.

How do I check if the selection is made in one of a set of controls?
Thanks for your help
Anand
 
M

Martin Honnen

How do I figure out if a selection in a document is in a particular
control?
I have a TEXTAREA in which a user can type in some text, select some
text and 'apply' tags around it clicking a button. I am using
document.selection.createRange() to create a textRange object and then
modify its text property to suit the action. But the problem is I want
to limit this action to a few "INPUT type=text" and TEXTAREA controls.

How do I check if the selection is made in one of a set of controls?

var range = document.selection.createRange();
var textarea = document.forms.formName.elements.textareaName;
if (range.parentElement() = textarea) {
...
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top