I am trying to setup some bold, italic and underline buttons for my textarea, I am using this code to make the switch from normal to bold/italic/underline.
document.execCommand("bold", false, "");
It works perfect in Chrome, but in Firefox and ie it doesn't change the text to bold or anything and I cannot work out why?
Here is the full code:
<input name="new_shout_bold" type="button" class="new_shout_text_option" id="new_shout_bold" onclick='document.execCommand("bold", false, "");' value="B" alt="B" />
<input name="new_shout_italic" type="button" class="new_shout_text_option" onclick='document.execCommand("italic", false, "");' value="I" alt="I" style="font-style: italic;"/>
<input name="new_shout_underline" type="button" class="new_shout_text_option" onclick='document.execCommand("underline", false, "");' value="U" alt="U" style="text-decoration: underline;" />
Here is the textarea:
<div id="dash_new_shout_textarea" name="dash_new_shout_textarea" class="dash_new_shout_textarea" contenteditable="true"></div>
Any Ideas?
通过向 HTML 标记添加unselectable="on"
使按钮在 IE 中unselectable="on"
。
I know this won't help too much, but this code works perfectly fine in Chrome and Firefox
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.