javascript - Preview Entire Document Typed in Textarea in New Window -
I am creating a simple code editor for writing HTML / CSS / JS files online and offline. So far, everything is going well, but I am trying to explain how to properly preview a complete HTML document that is written in the editor, operating system and all. So far for the editor, you can use "open in new tab" to open the document in a new window.
However, the only way I want to create this is to use a base 64 encoded HTML file, allowing me to output a whole document to a window, methodology and everyone. it occurs.
If I say, previewWinRef.document.write (editor.value)
, after trying, which would not work, it was all attached to the current document.
How can I clear the content of the preview window of my entirety and how can I write the full value of the editor in the preview window based on the text base64 encoding?
[edit]: What is happening in code:
editor.addEventListener ('keydown', function (event) {setTimeout (function () {If ( PreviewWinRef) {previewWinRef.location = "data: text / html; base64," + Base64.encode (editor.value);}}, 100);}); Actually I'm refreshing the result every time when you press a key, only when you open in the File-> New tab, but the preview window is open. For some reason, I can not be able to access the preview window document, even though the editor window created it and it's just a data url? Window {}
Try it:
var win = window.open ("about: blank", "title"); Win.document.getElementsByTagName ("html") [0]. WinnerHTML = document.body.getElementsByTagName ("textarea") [0]. value;
Comments
Post a Comment