Skip to content

Instantly share code, notes, and snippets.

@sorrat
Last active November 17, 2016 15:48
Show Gist options
  • Save sorrat/b5538dc2564776fedd2fc859385c9bc0 to your computer and use it in GitHub Desktop.
Save sorrat/b5538dc2564776fedd2fc859385c9bc0 to your computer and use it in GitHub Desktop.
Iframe with variable src
<!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