-
Notifications
You must be signed in to change notification settings - Fork 33
/
iframe.html
59 lines (39 loc) · 914 Bytes
/
iframe.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
48
49
50
<!doctype html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container grid">
<form>
<h2>HTML</h2>
<textarea id="html"></textarea>
<h2>CSS</h2>
<textarea id="css"></textarea>
</form>
</div>
<div class="output grid">
<iframe></iframe>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://localhost:35729/livereload.js"></script>
<script>
(function() {
$('.grid').height( $(window).height() );
var contents = $('iframe').contents(),
body = contents.find('body'),
styleTag = $('<style></style>').appendTo(contents.find('head'));
$('textarea').keyup(function() {
var $this = $(this);
if ( $this.attr('id') === 'html') {
body.html( $this.val() );
} else {
// it had to be css
styleTag.text( $this.val() );
}
});
})();
</script>
</body>
</html>