Last active
November 17, 2016 15:48
-
-
Save sorrat/b5538dc2564776fedd2fc859385c9bc0 to your computer and use it in GitHub Desktop.
Iframe with variable src
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test iframe</title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
function changeIframeSrc() { | |
var now = new Date(); | |
var iframe = document.getElementById(iframeId); | |
iframe.src = 'http://192.168.5.2/' + now.getDay() + '.html'; | |
} | |
function createIframe() { | |
var iframe = document.createElement('iframe'); | |
iframe.id = iframeId; | |
iframe.style.width = '1850px'; | |
iframe.style.height = '250px'; | |
document.body.appendChild(iframe); | |
} | |
function startup() { | |
var DAY = 24 * 60 * 60 * 1000; | |
createIframe(); | |
changeIframeSrc(); | |
setInterval(changeIframeSrc, DAY); | |
} | |
var iframeId = 'some-iframe'; | |
startup(); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment