javascript - how can i define iframe to have null content? -


i have code , want after every click content of iframe null , later

<div id="code" contenteditable></div> <iframe id="output"></iframe> <button onclick="update()">run</button>  <script> function update() { var frame = document.getelementbyid("output"); var framedoc = frame.contentdocument || frame.contentwindow.document; var w = document.getelementbyid("code").textcontent;  //************************************ //here want change frame.contentwindow === null; frame.contentwindow.document.write(w); //************************************ } </script> <style> #code{ width:47%; height:81.8%; border:1px solid; } #output{ width:47%; height:80%; border:1px solid; position:absolute; right:0px; top:0px; }  </style> 

thank (-;

p.s.- try make editor

you need

frame.contentwindow.document.close();  

after each write, next write clear it.

also why not use framedoc have it?

function update() {   var w = document.getelementbyid("code").textcontent;   var frame = document.getelementbyid("output");   var framedoc = frame.contentdocument || frame.contentwindow.document;   framedoc.write(w);    framedoc.close();  } 

also make button type="button browsers submit page if not


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -