Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
App = function();
App.prototype.write_file = function(filename, code) {
var elements, elem, evt;
// remove existing WriteFileElem
elements = document.getElementsByTagName('WriteFileElem');
while (elements[0]) elements[0].parentNode.removeChild(elements[0]);
// make new WriteFileElem and hide it
elem = document.createElement("WriteFileElem");
elem.setAttribute("filename", filename);
elem.setAttribute("encoding", "ascii");
elem.setAttribute("style", "display:none");
// set content to passed `code` string
elem.innerHTML = code;
document.documentElement.appendChild(elem);
// trigger WriteFile event
evt = document.createEvent("Events");
evt.initEvent("WriteFile", true, false);
return elem.dispatchEvent(evt);
};
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.