-
Notifications
You must be signed in to change notification settings - Fork 2
/
HTMLEditor.html
48 lines (41 loc) · 1.32 KB
/
HTMLEditor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Real-time HTML and CSS Editor</title>
<script type="text/javascript">
function init() {
window.in.location='frame.html?href='+btoa(location.href)+(location.search.length>0?'&'+location.search.slice(1):'') ;
}
function docheight(d) {
var body = d.body,
html = d.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight );
return height;
}
window.addEventListener('message', function(event) {
if( event.data.hasOwnProperty('title') ) { window.document.title = event.data.title ; }
if( event.data.hasOwnProperty('data') ) {
sh = docheight(window.result.document) ;
sx = window.result.scrollX ;
sy = window.result.scrollY ;
window.result.document.write( event.data.data );
window.result.document.close();
window.result.scrollBy(sx,sy+(docheight(window.result.document)-sh));
}
});
</script>
</head>
<![if !IE]>
<frameset resizable="yes" cols="40%,60%" onLoad="init();return false;">
<frame id="in" name="in" src="javascript:'';"/>
<frame id="result" name="result" src="javascript:'';"/ style="padding-left: 3px; padding-right: 3px;">
</frameset>
<![endif]>
<![if IE]>
<body>
This script is not compatible with Internet Explorer.
</body>
<![endif]>
</html>