-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwithout_codemirror.html
More file actions
116 lines (105 loc) · 2.37 KB
/
without_codemirror.html
File metadata and controls
116 lines (105 loc) · 2.37 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tryit editor - Webtutorials.ME</title>
<style>
*{
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
background: #f2f2f2;
font-family: sans-serif;
padding: 50px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
.container-wrapper {
display: flex;
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
flex-wrap: wrap;
border: 1px solid #cccccc;
padding: 10px;
background: #ffffff;
}
.container-wrapper div {
flex: 1;
}
.code-area {
width: 100%;
height: 400px;
resize: none;
overflow-y: auto;
white-space: pre-wrap;
outline: none;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
}
.run-code-btn {
float: right;
margin-bottom: 10px;
padding: 10px 20px;
text-transform: uppercase;
cursor: pointer;
background: #333333;
border: 1px solid rgba(0, 0, 0, .1);
color: #ffffff;
outline: none;
transition: all .3s;
}
.run-code-btn:hover {
border-color: #333333;
color: #222222;
background: #ffffff;
}
.iframe_style {
width: 100%;
height: 100%;
border: 1px solid #cccccc;
}
.CodeMirror {
border: 1px solid #cccccc;
width: 100%;
height: 400px;
}
.iframe-container {
padding-left: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="container-wrapper">
<div class="code-containter">
<button class="run-code-btn" id="run_btn">Run</button>
<textarea name="code_area" class="code-area" id="code_area"></textarea>
</div>
<div class="iframe-container">
<iframe class="iframe_style" id="iframe"></iframe>
</div>
</div>
</div>
<script>
/* MAIN FUNCTION FOR RENDERING TEXTAREA CODE TO IFRAME */
function run_code() {
var iframe = document.getElementById('iframe');
iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument) ? iframe.contentDocument.document : iframe.contentDocument;
iframe.document.open();
iframe.document.write(document.getElementById('code_area').value);
iframe.document.close();
return false;
}
//WHEN CLICKED RUN BUTTON
document.getElementById('run_btn').addEventListener('click', function() {
run_code();
});
</script>
</body>
</html>