简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM