-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHTML Compiler.html
More file actions
71 lines (68 loc) · 1.73 KB
/
HTML Compiler.html
File metadata and controls
71 lines (68 loc) · 1.73 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
<html>
<!--Learning Javascript DOM-->
<head>
<style>
textarea,
iframe {
border: 2px solid black;
height: 80vh;
width: 100%;
}
button {
padding: 12px 12px;
border: 1px solid black;
border-radius: 20px 20px 20px 20px;
width: 200px;
}
button:hover {
background-color: #ffe680;
}
#sr{
height:80vh;
}
</style>
</head>
<body>
<div style="border :10px solid #ffe680;" height="78vh;">
<br>
<center>
<button onclick="run();"><b>Run</b></button>
</center>
<table width="100%" border="0" cellspacing="0" cellpadding="5" height="700vh">
<br>
<tr>
<td width="50%"> </td>
<td width="50%" align="left"></td>
</tr>
<tr id="sr">
<td>
<form>
Code:<br>
<textarea name="src" id="sourcecode">
</textarea>
</form>
</td>
<td>Output :<br>
<iframe name="tc" id="targetcode"></iframe>
</td>
</tr>
</table>
</div>
<script>
function run() {
var content = document.getElementById('sourcecode').value;
//console.log(content);
var iframe = document.getElementById('targetcode');
iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument) ?
iframe.contentDocument.document : iframe.contentDocument;
//learning document object and window object in javascript
//document.write(iframe.contentWindow);
iframe.document.open();
iframe.document.write(content);
iframe.document.close();
return false;
}
run();
</script>
</body>
</html>