好的,一些夥計們會知道我的意思,並編輯我的問題,但他們做錯了。execCommand的替代方法('underline');
一個更好的解釋:
你有CONTENTEDITABLE div
與文本This is a Test String.
。 如果您現在使用execCommand('underline')
對Test String
您得到This is a <u>Test String</u>
如果您現在使用execCommand('strikethrough')
對is a Test
您得到This <s>is a <u>Test</u></s><u>String</u>
,這是正確的。
因此,在HTML5中<u>
和<s>
已過時。 對於第一個execCommand
,您可以使用surroundContents()
和<span style="text-decoration:underline;">
。如果您現在使用surroundContets()
作爲第二個execCommand
,則會收到BAD_BOUNDARYPOINTS_ERR
。
我想要的東西是一個函數,它在這種情況下的工作方式與execCommand
類似,但是函數中我可以用巫婆HTML-Tag定義字符串將被包裹...(它應該是智能的,如果有任何重疊... )
除Javascript和HTML5外,還有一些涉及到的內容。 – Pointy 2010-06-13 16:29:07