GilbertClaus commited on
Commit
b22b57b
·
1 Parent(s): d1154cb

urlInject

Browse files
Files changed (1) hide show
  1. index.html +26 -28
index.html CHANGED
@@ -43,35 +43,33 @@
43
  </style>
44
  </head>
45
  <body>
46
-
47
- <header>
48
- <input type="text" id="urlInput" placeholder="Masukkan URL">
49
- <button onclick="loadWebsite()">Load</button>
50
- <button onclick="ark()">Ark ReCode</button>
51
- </header>
52
-
53
- <iframe id="viewer"></iframe>
54
-
55
- <script>
56
- function loadWebsite(urlInject = "") {
57
- const inputField = document.getElementById("urlInput");
58
- const iframe = document.getElementById("viewer");
59
-
60
- // Gunakan urlInject jika disediakan, jika tidak pakai input dari user
61
- const url = urlInject !== "" ? urlInject : inputField.value;
62
-
63
- if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith(".")) {
64
- iframe.src = url;
65
- } else {
66
- alert("URL harus diawali dengan http:// atau https://");
67
- }
68
- }
69
 
70
- function ark() {
71
- loadWebsite("./ArkReCode");
72
- }
73
-
74
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  </body>
77
  </html>
 
43
  </style>
44
  </head>
45
  <body>
46
+ <header>
47
+ <input type="text" id="urlInput" placeholder="Masukkan URL">
48
+ <button onclick="loadWebsite()">Load</button>
49
+ <button onclick="loadWebsite('./ArkReCode')">Ark ReCode</button>
50
+ </header>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ <iframe id="viewer"></iframe>
53
+
54
+ <script>
55
+ function loadWebsite(urlInject = "") {
56
+ const inputField = document.getElementById("urlInput");
57
+ const iframe = document.getElementById("viewer");
58
+
59
+ // Pakai urlInject kalau disediakan, kalau tidak ambil dari input
60
+ const url = urlInject || inputField.value;
61
+
62
+ // Cek apakah URL valid (dimulai dengan http/https atau file lokal)
63
+ const isValidHttp = url.startsWith("http://") || url.startsWith("https://");
64
+ const isLocalFile = url.startsWith(".") || url.endsWith(".html");
65
+
66
+ if (isValidHttp || isLocalFile) {
67
+ iframe.src = url;
68
+ } else {
69
+ alert("URL harus diawali dengan http://, https://, atau merupakan file lokal .html");
70
+ }
71
+ }
72
+ </script>
73
 
74
  </body>
75
  </html>