I'm afraid that the only answer is "just because". Don't expect that there's a reason behind how something works in contenteditable
. I experienced hundreds of times that no one really cared or had time to care about that. When you've got bugs like https://code.google.com/p/chromium/issues/detail?id=226941 which make contenteditable totally irritating for users on Chrome & Opera and which hasn't been even confirmed by developers throughout entire year, then a small difference in Tab's behaviour is a detail which you have to fix and forget ;).
Pressing tab in a contenteditable control using webkit
-
14-06-2023 - |
Вопрос
I'm working with a contenteditable iframe that is being using for basic WYSIWYG editing. I've noticed a strange difference in the way that a Tab keypress event is handled between Chrome and Firefox.
When the document of the iframe has been configured using designMode = 'On'
, a tab pressed inside the document will skip to the next control in Firefox (expected) but create the following pre white-spaced span in Chrome
<span class="Apple-tab-span" style="white-space:pre"> </span>
Interestingly, when the body of the iframe is setup instead using body.setAttribute("contenteditable", "true")
, which I assumed was the same approach done in a different way, both browsers work as i would expect; moving the focus to the next tab index.
Can anyone explain why?
Решение
Другие советы
Use:
document.designMode = 'on';
Insted of
body.setAttribute("contenteditable", "true")
Не связан с StackOverflow