-
Notifications
You must be signed in to change notification settings - Fork 190
/
auto refresher.html
54 lines (53 loc) · 1.72 KB
/
auto refresher.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Auto Refresh Iframe</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
input, button {
padding: 10px;
margin: 10px;
font-size: 16px;
}
iframe {
width: 80%;
height: 400px;
border: 1px solid #ccc;
margin-top: 20px;
}
</style>
<script>
let refreshInterval;
function startAutoRefresh() {
const url = document.getElementById('url').value;
const interval = document.getElementById('interval').value * 1000;
if (url && interval) {
document.getElementById('autoRefreshIframe').src = url;
if (refreshInterval) {
clearInterval(refreshInterval);
}
refreshInterval = setInterval(() => {
document.getElementById('autoRefreshIframe').src = url;
}, interval);
} else {
alert("Please enter a valid URL and interval.");
}
}
</script>
</head>
<body>
<h1>Auto Refresh Iframe</h1>
<label for="url">URL to refresh:</label>
<input type="text" id="url" placeholder="https://example.com"><br>
<label for="interval">Refresh interval (in seconds):</label>
<input type="number" id="interval" min="1" step="1"><br>
<button onclick="startAutoRefresh()">Start Auto Refresh</button>
<iframe id="autoRefreshIframe" src="" frameborder="0"></iframe>
</body>
</html>