I’ve been calling execCommand on the document to make the selected text bold or to set its color. But recently I need to use execCommand on a certain range and not the selected text.
Can I do this and if so how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can, but it needs to be the selection. So in other words, do the following:
RangeexecCommandYou can create a
selectionfrom ranges (non-IE browsers) with the following:With IE, you can directly execute
execCommandonTextRangeobjects, so this whole process won’t be necessary.