![](/img/trans.png)
[英]Javascript document.execCommand “bold” not working in chrome
[英]document.execCommand('bold') not working in react js
REACT JS:我正在嘗試為我的項目創建簡單的編輯器,該編輯器可以使文本加粗,斜體和下划線
即時通訊使用contentEditable
<div className="inputBox" contentEditable>some text here to play with</div>
我使用它上方的按鈕使文本變為粗體
<div className="button' onClick={this.buttonCLick.bind(this)}>BOLD</div>
這稱為onclick
buttonCLick(){
let isWorking = document.execCommand('bold',false,'');
console.log('isWorking:', isWorking);
}
但是“ isWorking
”每次都返回false
,所選文本不會發生任何事情。
哪個瀏覽器顯示此行為? 您是否在其他瀏覽器上嘗試過?
例如,在Firefox上,您必須確保默認字體粗細為400( https://bugzilla.mozilla.org/show_bug.cgi?id=948411 )。 在這里,我已經報告了Firefox的文檔錯誤https://bugzilla.mozilla.org/show_bug.cgi?id=1515267
另一個奇怪的情況似乎是這種情況,但我沒有重現這一點: 當我單擊div時 , 為什么document.execCommand不起作用? 但
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.