I am storing to current url of an iframe in sessionstorage and then refreshing after a set time then reloading the iframe with the current url. But it will work for about 2-3 refreshes then it fails and goes to the iframe src URL. Can someone tell me how to optimize this script so it will work everytime.
<script>
if (sessionStorage.getItem('url') == null) {
window.location;
} else{
document.getElementById("iframe").src = sessionStorage.getItem('url');
};
sessionStorage.removeItem('url');
setTimeout(refresh, 500000);
function refresh () {
document.domain = 'company.com';
var myURL = document.getElementById("iframe").contentWindow.location.href;
sessionStorage.setItem('url', myURL);
window.location = window.location;
};
</script>
Aucun commentaire:
Enregistrer un commentaire