Re: XUL - How i get the code from the open website?
Neil <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xpfe |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: >var test = content.document.body; // i get the HTMLBodyElement > >here i see the properties >https://developer.mozilla.org/en-US/docs/DOM/HTMLBodyElement > >i cant see a possibility to extract the code from the body node. is there a method how i can do this? > >for example i will extract the code from a website that contains only in the body node. then i will strip all html tags. in php there is the function strip_tags. > >is this possible with javascript? > The easiest method is to return content.document.body.textContent but that will also return the contents of <script> and <style> elements, which may not by what you want. Another approach is to use a Range object: var range = content.document.createRange(); range.selectNodeContents(content.document.body); return range.toString(); You get a slightly different result if you use the Selection object: content.getSelection().selectAllChildren(content.document.body); return content.getSelection().toString(); After that you have to start looking at XPCOM serialiser objects. -- Warning: May contain traces of nuts.