Why Doesn't The Document.execCommand Work When I Click On A Div?
Both the button and the div have the same 'onclick' code, yet the execCommand only seems to work on the button. Is there any way I can make it work when pressing the div? Here's my
Solution 1:
You need to prevent the mousedown
event on your div because it steals the focus:
Solution 2:
See this fiddle :- http://jsfiddle.net/ZzL8y/4/
This is not the complete answer but these links might help you:-
1> set execcommand just for a div
2> select all text in contenteditable div when it focus/click
Solution 3:
For Firefox, it's necessary to set contenteditable = true before execCommand.
For IE it is not necessary.
Post a Comment for "Why Doesn't The Document.execCommand Work When I Click On A Div?"