Skip to content

Instantly share code, notes, and snippets.

@d136o
Created February 25, 2016 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save d136o/4f2ad306add55d2478f3 to your computer and use it in GitHub Desktop.
Save d136o/4f2ad306add55d2478f3 to your computer and use it in GitHub Desktop.
Cycle through urls on an iframe
html>
<body>
<script type="text/javascript">
var urls = [
"https://duckduckgo.com",
"https://bing.com",
]
var UPDATE_FREQ = 10*1000;
var current_url = 0;
var iframe = document.createElement("iframe");
iframe.width = "100%";
iframe.height = "100%";
function update_url() {
current_url = (current_url + 1) % (urls.length);
iframe.src = urls[current_url];
console.log("set url to " + urls[current_url]);
setTimeout(update_url, UPDATE_FREQ);
}
console.log("starting url cycling");
document.body.appendChild(iframe);
setTimeout(update_url, 0);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment