+ 2

I have build a live code editor but it is not showing output in the iframe and it is saying undefined please help me

https://code.sololearn.com/Wdo0v1XXCN73/?ref=app

2nd Jul 2022, 1:27 PM
Saddam Hussain
Saddam Hussain - avatar
3 odpowiedzi
+ 4
You need to change JS code like below. let editor = ace.edit("editor", { theme: "ace/theme/cobalt", mode: "ace/mode/html", autoScrollEditorIntoView: true, enableBasicAutocompletion: true, enableSnippets: true, enableLiveAutocompletion: true, }); function live() { document.getElementById("viewer").srcdoc =editor.getValue(); }
2nd Jul 2022, 3:24 PM
Oleh Davydenko
Oleh Davydenko - avatar
+ 2
L1c Bot Use innerHTML because you are getting value from html element not from input box var editor = document.getElementById("editor").innerHTML
2nd Jul 2022, 1:51 PM
A͢J
A͢J - avatar
+ 2
Thanks to A͢J , Oleh Davydenko for your help it is now working 😊😊😉
3rd Jul 2022, 4:01 AM
Saddam Hussain
Saddam Hussain - avatar