Spaces:
Running
Running
File size: 1,826 Bytes
31d903b b05b4ac 0bcdffe b05b4ac 9b11c4a b05b4ac 9b11c4a b05b4ac 9b11c4a b05b4ac b22b57b 8fb6476 b22b57b 1138c88 b22b57b 0bcdffe | 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 | <!DOCTYPE html>
<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>
|