好的,一些伙计们会知道我的意思,并编辑我的问题,但他们做错了。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