By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

question relating to document.selection

P: n/a
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

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


c.**********@gmail.com wrote:

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) {
...
}
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.