Created
February 25, 2016 17:39
-
-
Save d136o/370fddccb57a65d6094c to your computer and use it in GitHub Desktop.
Cycle through urls on an iframe
This file contains 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
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