amercader
amercader

Reputation: 4540

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

Upvotes: 2

Views: 434

Answers (2)

Phong
Phong

Reputation: 6768

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!

Upvotes: 3

Phong
Phong

Reputation: 6768

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

Upvotes: 1

Related Questions