Created
July 9, 2012 15:07
-
-
Save rocktronica/3077065 to your computer and use it in GitHub Desktop.
refresh page w/ iframe
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
(function(win, doc, body){ | |
var iCounter = 0, sUrl = doc.location.href, sTitle = doc.title || sUrl, | |
iMinutes = parseFloat(prompt("Seconds till refresh", "60"),10) || 60; | |
doc.head.innerHTML = body.innerHTML = ''; | |
body.style.overflow = 'hidden'; | |
var iframe = win.iframe = doc.createElement("iframe"); | |
iframe.src = doc.location.href; | |
iframe.setAttribute('style', | |
'position:absolute;top:0;left:0;width:100%;height:100%;border:0' | |
); | |
body.appendChild(iframe); | |
iframe.onLoad = function() { | |
iCounter++; | |
doc.title = iCounter + ': ' + sTitle; | |
}; | |
iframe.cycle = function() { | |
iframe.setAttribute('src', sUrl); | |
iframe.setAttribute('onLoad', 'iframe.onLoad()'); | |
}; | |
iframe.cycle(); | |
setInterval(iframe.cycle, iMinutes*1000); | |
}(window, document, document.body)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Big, hopefully obvious caveat: the page must not disallow iFrames.