How to make iframe contenteditable ?
‘ondblclick="frameToDiv()’ not working either , perhaps because iFrame isnt working .
How can I fix this:
<!DOCTYPE html>
<html>
<body contenteditable="true" >
<div id="input" ondblclick="divToFrame()" contenteditable="true"
style="float:left; width: 400px; height: 400px; border: 2px solid green;">
Edit content here. Double-click to view content in the iframe.
</div>
<p>
<iframe id="output" ondblclick="frameToDiv()" contenteditable="true"
style="display:inline-block; width:400px; height:400px; border: 2px solid red;">
</iframe>
</p>
<script>
function frameToDiv() {
console.log("function frameToDiv()")
}
function divToFrame() {
console.log("function divToFrame()")
let data = document.getElementById("input").innerHTML;
let iframeDoc = document.getElementById("output").contentDocument;
iframeDoc.documentElement.innerHTML = data;
}
</script>
</body>
</html>
Thanks