-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (29 loc) · 827 Bytes
/
script.js
File metadata and controls
36 lines (29 loc) · 827 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
let intervalId;
function isValidUrl(string) {
try {
new URL(string);
return true;
} catch (_) {
return false;
}
}
function setupIframe() {
const urlInput = document.getElementById("urlInput").value.trim();
const timeInput = parseInt(document.getElementById("timeInput").value.trim(), 10);
const iframe = document.getElementById("iframeView");
if (!isValidUrl(urlInput)) {
alert("Please enter a valid URL.");
return;
}
if (isNaN(timeInput) || timeInput <= 0) {
alert("Please enter a valid time in seconds.");
return;
}
iframe.src = urlInput;
if (intervalId) {
clearInterval(intervalId);
}
intervalId = setInterval(() => {
iframe.src = urlInput;
}, timeInput * 1000);
}