public
Created

  • Download Gist
app.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
App = function();
 
App.prototype.write_file = function(filename, code) {
var elem, evt;
$("WriteFileElem").remove();
elem = document.createElement("WriteFileElem");
elem.setAttribute("filename", filename);
elem.setAttribute("encoding", "ascii");
elem.setAttribute("style", "display:none");
elem.innerHTML = code;
document.documentElement.appendChild(elem);
evt = document.createEvent("Events");
evt.initEvent("WriteFile", true, false);
return elem.dispatchEvent(evt);
};
firefox-extension-writefile.html
HTML
1 2 3 4 5 6 7
<html>
<body>
<WriteFileElem filename="/Users/joe/Desktop/writefile.txt" encoding="ascii">
innerHTML of this element will be written to filename attribute value, if it doesn't already exist.
</WriteFileElem>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.