Created
April 20, 2021 23:34
-
-
Save dublado/38228a0631babf9db86fe7bdc974aacc to your computer and use it in GitHub Desktop.
Real-time HTML Editor - Welcome to the real-time HTML editor! Type HTML in the textarea above, and it will magically appear in the frame below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Real-time HTML Editor - http://htmledit.squarefree.com/</title> | |
<script type="text/javascript"> | |
var editboxHTML = | |
'<html class="expand close">' + | |
'<head>' + | |
'<style type="text/css">' + | |
'.expand { width: 100%; height: 100%; }' + | |
'.close { border: none; margin: 0px; padding: 0px; }' + | |
'html,body { overflow: hidden; }' + | |
'<\/style>' + | |
'<\/head>' + | |
'<body class="expand close" onload="document.f.ta.focus(); document.f.ta.select();">' + | |
'<form class="expand close" name="f">' + | |
'<textarea class="expand close" style="background: #def;" name="ta" wrap="hard" spellcheck="false">' + | |
'<\/textarea>' + | |
'<\/form>' + | |
'<\/body>' + | |
'<\/html>'; | |
var defaultStuff = '<h3>Welcome to the real-time HTML editor!<\/h3>\n' + | |
'<p>Type HTML in the textarea above, and it will magically appear in the frame below.<\/p>'; | |
// I don't want this stuff to appear in the box at the top because I feel it's likely to be distracting. | |
var extraStuff = '<div style="position:absolute; margin:.3em; bottom:0em; right:0em;"><small>\n Created by <a href="http://www.squarefree.com/" target="_top">Jesse Ruderman<\/a> and hosted by <a href="http://www.dreamhost.com/rewards.cgi?jesseruderman" target="_top">DreamHost<\/a>.\n<\/small><\/div>'; | |
var old = ''; | |
function init() | |
{ | |
window.editbox.document.write(editboxHTML); | |
window.editbox.document.close(); | |
window.editbox.document.f.ta.value = defaultStuff; | |
update(); | |
} | |
function update() | |
{ | |
var textarea = window.editbox.document.f.ta; | |
var d = dynamicframe.document; | |
if (old != textarea.value) { | |
old = textarea.value; | |
d.open(); | |
d.write(old); | |
if (old.replace(/[\r\n]/g,'') == defaultStuff.replace(/[\r\n]/g,'')) | |
d.write(extraStuff); | |
d.close(); | |
} | |
window.setTimeout(update, 150); | |
} | |
</script> | |
</head> | |
<frameset resizable="yes" rows="50%,*" onload="init();"> | |
<!-- about:blank confuses opera, so use javascript: URLs instead --> | |
<frame name="editbox" src="javascript:'';"> | |
<frame name="dynamicframe" src="javascript:'';"> | |
</frameset> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment