开发者

execCommand not working for xml file

I am using execCommand command to 'Hilite' selected text on the page which is rendered with gecko engine/gtkmozembed.

if ( !document.execCommand("HiliteColor", false, colour) ) {
                document.execCommand("BackColor", false, colour);
}

This is working fine with HTML pages. But i have some XML pages( books in xml format). execCommand is not开发者_如何学编程 working for those XML pages. It gives warning like

TypeError: document.execCommand is not a function      

How can i make execCommand works on XML? Thanks.


XML has no visual representation layer by default. It is only a data container. Try transforming the XML documents into HTML documents using XSLT. Then any JavaScript will work perfectly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜