Load a dynamically created document in the browser from a Firefox extension
Is there a way to load a DOM document dynamically created from the scope of a Firefox extension to a tab in the current browser?
I would like to create an HTML report from a Firefox ex开发者_高级运维tension and load it in a new tab in the browser.
var doc = document.implementation.createDocument ('http://www.w3.org/1999/xhtml', 'html', null);
var body = document.createElementNS('http://www.w3.org/1999/xhtml', 'body');
doc.documentElement.appendChild(body);
var div = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
div.appendChild(document.createTextNode("New HTML doc");
body.appendChild(div)
//How to load this document in a new tab?
So far, I have only achieved to append the dynamically generated content in the body of an empty template located in the extension directory (chrome://myextension/content/template.html).
Any help would be greatly appreciated.
For the file manipulation, you will need is the following:
- temporary file creation
- Write in a file
Load a file in a new firefox tab:
- Add Firefos Tab
Some useful link to continue:
- Mozilla site for development
- Add-ons for Firefox: Just download and read the source code of extension is maybe the best self-teaching way to learn.
I hope this will help you, Good continuation!
It may not be exactly what you want but one solution would be to simply create a file in the temporary directory of the system and to open it in a new tab of your firefox
精彩评论