views:

87

answers:

2

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 extension 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.

A: 

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

Phong
That would be ok, can you give some clues on how to do it or point me to an online example / documentation?
amercader
I put a new post for that purpose, I hope you like it!
Phong
+2  A: 

Hi,

For the file manipulation, you will need is the following:

Load a file in a new firefox tab:

Some useful link to continue:

I hope this will help you, Good continuation!

Phong