How to make a real-time HTML viewer
<html>
<head>
<title>Real Time Editor</title>
<body>
<SCRIPT language=JavaScript>
function right(e) {
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) {
a=window.open("https://www.google.com","WindowName","width=640,height=600,top=40,left=50,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no");
return false;
}
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
a=window.open("https://www.sitiosargentina.com.ar/","WindowName","width=640,height=600,top=40,left=50,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no");
return false;
}
return true;
}
document.onmousedown=right;
window.onmousedown=right;
</SCRIPT>
<script>
function refresh(){
var textContent = document.getElementById('editor-textarea').value; document.getElementById('viewer').srcdoc = textContent;
}
</script>
<script type="text/javascript">
alert("Esta página web es sólo para fines educativos.");
</script>
<style>
*{
padding: 0;
margin: o;
}
.main{
background:#ecf0f1;
width: 100%;
height: 100%;
display: inline-flex;
}
#editor-textarea{
width: 100%;
height: 95%;
margin: 10px;
padding: 5px;
}
#viewer{
background: white;
border: none;
width: 100%;
height: 95%;
margin: 10px;
border: 1px solid #3498db;
}
</style>
</head>
<div class="main">
<textarea id="editor-textarea" onkeyup = "refresh()" placeholder="Empezar a programar..."></textarea>
<iframe id="viewer"></iframe>
</div>
</body>
</html>
Comentarios
Publicar un comentario