-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser.html
55 lines (51 loc) · 1.36 KB
/
browser.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
51
52
53
54
55
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<meta name="Author" content=""/>
<style>
.main div {
display: inline-block
}
.code-hide {
display: none;
}
</style>
</head>
<body>
<div class="main">
<div class="code-area">
<textarea class="code-body">
<html>
<head>
<style>
p {
color: red
}
</style></head>
<body>
<p>Hello</p></body>
</html>
</textarea>
<div class="code-hide">
</div>
</div>
<div>
<button onclick="preview()">Run</button>
</div>
<div class="preview-area">
</div>
</div>
<script>
preview()
function preview() {
const codeBody = document.getElementsByClassName('code-body');
const codeHide = document.getElementsByClassName('code-hide');
const previewArea = document.getElementsByClassName('previewArea');
codeHide[0].innerHTML = codeBody[0].value
previewArea[0].innerHTML = codeHide.outerHTML
}
</script>
</body>
</html>