javascript
Load or preview html to Iframe using Javascript only
You can use the code to preview your HTML code to iframe or writing your HTML, CSS and Js code to iframe
var html = '';
html += '<!DOCTYPE html>\n';
html += '<html lang="en">\n';
html += '<head>\n';
html += '</head>\n';
html += '<body>\n';
html += '<div>Hello World we are here...</div>';
html += '</body>\n';
html += '</html>';
(document.getElementById("iframe_id").contentWindow.document).write(html);
(document.getElementById("iframe_id").contentWindow.document).close();
Was this helpful?
Similar Posts
- jQuery code to run a function after page load
- Check whether a checkbox is checked or not using Javascript only
- How to make HTTP requests using Javascript Only
- Check if video is stopped or playing Javascript only
- Editorjs blocks - JSON to HTML javascript
- Enter only number field validation redux form
- Render a string as HTML in React