-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (31 loc) · 995 Bytes
/
Copy pathscript.js
File metadata and controls
37 lines (31 loc) · 995 Bytes
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
// جلب عناصر المحرر
const htmlInput = document.getElementById("html-code");
const cssInput = document.getElementById("css-code");
const jsInput = document.getElementById("js-code");
// جلب iframe لعرض النتيجة
const resultFrame = document.getElementById("result");
function updatePreview() {
// محتوى المستخدم
const html = htmlInput.value;
const css = cssInput.value;
const js = jsInput.value;
// دمج الأكواد في مستند واحد
const output = `
<!DOCTYPE html>
<html>
<head>
<style>${css}</style>
</head>
<body>
${html}
<script>${js}<\/script>
</body>
</html>
`;
// عرض النتيجة داخل iframe
resultFrame.srcdoc = output;
}
htmlInput.addEventListener("input", updatePreview);
cssInput.addEventListener("input", updatePreview);
jsInput.addEventListener("input", updatePreview);
updatePreview();