Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Website Viewer</title> | |
| <style> | |
| body { | |
| margin: 0; | |
| font-family: sans-serif; | |
| background-color: #121212; | |
| color: #eee; | |
| display: flex; | |
| flex-direction: column; | |
| height: 100vh; | |
| } | |
| header { | |
| padding: 10px; | |
| background-color: #1f1f1f; | |
| display: flex; | |
| gap: 10px; | |
| } | |
| input { | |
| flex: 1; | |
| padding: 8px; | |
| background: #2a2a2a; | |
| color: white; | |
| border: 1px solid #444; | |
| border-radius: 4px; | |
| } | |
| button { | |
| padding: 8px 16px; | |
| background: #333; | |
| color: white; | |
| border: none; | |
| border-radius: 4px; | |
| cursor: pointer; | |
| } | |
| iframe { | |
| flex: 1; | |
| border: none; | |
| width: 100%; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <header> | |
| <input type="text" id="urlInput" placeholder="Masukkan URL"> | |
| <button onclick="loadWebsite()">Load</button> | |
| <button onclick="loadWebsite('./ArkReCode/index.html')">Ark ReCode</button> | |
| </header> | |
| <iframe id="viewer"></iframe> | |
| <script> | |
| function loadWebsite(urlInject = "") { | |
| const inputField = document.getElementById("urlInput"); | |
| const iframe = document.getElementById("viewer"); | |
| // Pakai urlInject kalau disediakan, kalau tidak ambil dari input | |
| const url = urlInject || inputField.value; | |
| // Cek apakah URL valid (dimulai dengan http/https atau file lokal) | |
| const isValidHttp = url.startsWith("http://") || url.startsWith("https://"); | |
| const isLocalFile = url.startsWith(".") || url.endsWith(".html"); | |
| if (isValidHttp || isLocalFile) { | |
| iframe.src = url; | |
| } else { | |
| alert("URL harus diawali dengan http://, https://, atau merupakan file lokal .html"); | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> | |