Recently, I created a script that allows me to build a web page in real-time. I can input HTML and CSS codes without any issues, but unfortunately, I am unable to execute JavaScript due to the limitations of the string-based editor I am using. Can anyone offer some guidance on how to enable JavaScript execution in this editor?
It's worth noting that this simple script allows me to input an entire webpage's code with CSS and HTML seamlessly, without any need for escaping characters, resulting in a formatted page. However, JavaScript functionality is not supported by this script.
function html() {
var str = document.getElementById("go").value;
document.getElementById("show").innerHTML = str;
}
<p id="show"></p>
<textarea id="go" onKeyUp="html()" width="100%" cols="50" rows="10">
</textarea>
UPDATE: Exciting news - I finally found a solution that allows this editor to execute JavaScript as well! Now, I can create a complete webpage with JavaScript functionalities integrated. Huge thanks to everyone who provided assistance!
$(document).ready(function(){
$('#editor').keyup(function(){
$('#page').html($(this).val());
});
});
<p id="page"></p>
<textarea id="editor" width="100%" cols="50" rows="10" placeholder="you can use HTML, CSS, and JavaScript here..."></textarea>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>