Last active
June 1, 2024 10:24
-
-
Save aliqorbani/7a44d078bd60f6019adebf4b661c14c1 to your computer and use it in GitHub Desktop.
reload a custom url using iframe and js with loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Reloading iframe using js</title> | |
</head> | |
<body> | |
<iframe marginwidth="0" id="inserts" marginheight="0" scrolling="no" src="" frameborder="0" style="height: 2em;padding: 0;margin: 0;width: 100%;"></iframe> | |
<p id="times"></p> | |
<script> | |
var times_reloaded = 0; | |
var iframe_src = 'URL_HERE'; | |
var loop_timeout = 3000; | |
window.setInterval("reloadIFrame();", loop_timeout); | |
function reloadIFrame() { | |
document.getElementById("inserts").src= iframe_src; | |
times_reloaded++; | |
document.title = times_reloaded + ' times reloaded'; | |
document.getElementById('times').innerHTML = 'times reloaded : ' + times_reloaded; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment