There is a way to do it with a javascript macro...
Something like:
Code: Select all
function writeFile(path,string,exact){//<versao>1.1</versao>
//http://stackoverflow.com/questions/14677247/imacro-setting-variable-saveas-csv
//import FileUtils.jsm
Components.utils.import("resource://gre/modules/FileUtils.jsm");
//declare file
var file = new FileUtils.File(path);
//declare file path
file.initWithPath(path);
//if it exists move on if not create it
if (!file.exists()){
file.create(file.NORMAL_FILE_TYPE, 0666);
}
var charset = 'UTF-8';
var fileStream = Components.classes['@mozilla.org/network/file-output-stream;1']
.createInstance(Components.interfaces.nsIFileOutputStream);
fileStream.init(file, 18, 0x200, false);
var converterStream = Components
.classes['@mozilla.org/intl/converter-output-stream;1']
.createInstance(Components.interfaces.nsIConverterOutputStream);
converterStream.init(fileStream, charset, string.length,
Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
//write file to location
if(!exact) string = "\r\n"+string;
converterStream.writeString(string);
converterStream.close();
fileStream.close();
}
var string = window.content.document.getElementById("content").innerHTML; //or outerHTML
var path = 'C:\content.html';
var exact = true;
writeFile(path,string,exact);
It won't be a html file, because there are no opening or closing of html, head and body. But you can add them to the string:
Code: Select all
string = '<html><head></head><body>'+string+'</body>';
The question is very old, and probably solved. But stays here for people with the same issues.