Something so simple is driving me nuts

Associate
Joined
28 Dec 2002
Posts
2,400
Location
Northern Ireland
Hi Guys,
I am trying to get an iframe to refresh every 30 seconds or so but I'm not getting anywhere.

This is the code I have so far and I'm hoping you guys can point out the problem which I have no doubt is very simple.

Code:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>BNL Team Studio</title>
<style type="text/css">
body {
	background-color: #FFFFFF;
}
</style>
</head>
<body>
<script>
window.setInterval("reloadIFrame();", 30000);

function reloadIFrame() {
 document.frames["gdocs"].location.reload();
}
</script>

<img src="http://team.bnlproductions.co.uk/wp-content/uploads/10402900_731387893579539_2034696032886340019_n.jpg" alt="BNL Productions" />

<p><iframe width="1500" height="700" frameborder="0" name="gdocs" scrolling="no" src="https://docs.google.com/spreadsheet/pub?*******y4d-dE5PRlZBdWFydmJscW9xeXpvWVByZ1E&single=true&gid=4&output=html&widget=true"></iframe><br>

<iframe src="http://www.bbc.co.uk/radio/player/bbc_radio_one" width="380" height="150" frameborder="0" ></iframe>
</p>
</p>
  
</iframe></p>
</body>
</html>
 
Permabanned
Joined
9 Aug 2008
Posts
35,707
meta tags in frame;
Code:
<meta http-equiv="refresh" content="30">

javascript;
Code:
<script>
window.setInterval("reloadIFrame();", 30000);

function reloadIFrame() {
 document.frames["frameNameHere"].location.reload();
}
</script>
 
Caporegime
Joined
18 Oct 2002
Posts
29,491
Location
Back in East London
ace2109 - You'll be getting cross-origin exceptions. Check your browser's dev console. There's no easy way around that.

mrbell1984 - if you actually read the post you'll see neither of those examples are helpful. The first is useless because I doubt OP has the access to inject a meta tag onto Google's site, and the latter is the exact same code that is already there. In fact all you've done is change the name of the frame.
 
Soldato
Joined
28 Oct 2006
Posts
12,456
Location
Sufferlandria
This is the error:
Code:
Refused to display 'https://docs.google[...]' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

edit: Actually, it may not be, just realised your link in OP has been truncated?
 
Associate
Joined
20 Oct 2007
Posts
776
Rather than reloading the iframe, update its src:

Code:
<script>
window.setInterval("reloadIFrame();", 30000);

function reloadIFrame() {
var src = document.frames["gdocs"].src;
 document.frames["gdocs"].src = '';
document.frames["gdocs"].src = src;
}
</script>

This will avoid any cross-domain javascript issues.
 
Back
Top Bottom