I am getting JS input code from a textarea and appending this into a Iframe body. then if any wrong syntax is input by user browser shows console errors. I want to show custom errors and stop console to show any errors. How can I do that in chrome or any other browsers ??
this is code
<textarea id="js" placeholder="Write JS / Jquery code here"></textarea>
<script>
jsContent='<script>' + $('#js').val() + '</script>';
$('body',targetIframe).append(jsContent);
</script>
output will be like this
<iframe id="preview" src="">
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body>
<scrip>textarea input goes here</script>
</body>
</html>
</iframe>