-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (30 loc) · 1.05 KB
/
script.js
File metadata and controls
36 lines (30 loc) · 1.05 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
document.getElementById('run-button').addEventListener('click', () => {
console.log('Run button clicked');
const html = document.getElementById('html-code').value;
console.log('HTML Input:', html);
const css = `<style>${document.getElementById('css-code').value}</style>`;
console.log('CSS Input:', css);
const js = `<script>${document.getElementById('js-code').value}<\/script>`;
console.log('JS Input:', js);
const iframeContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Preview</title>
${css}
</head>
<body>
${html}
${js}
</body>
</html>
`;
console.log('Generated Iframe Content:', iframeContent);
const iframe = document.getElementById('output');
const iframeDoc = iframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(iframeContent);
iframeDoc.close();
console.log('Iframe updated successfully');
});