admin管理员组文章数量:1023546
I have a situation where I need to refresh an iframe about every 30 seconds. I have looked through the forums and tried a few things, to no avail.
<iframe id="Doyle" src=".php"
width="375" height="560">
</iframe>
<script>
window.setInterval("reloadIFrame();", 3000);
function reloadIFrame() {
document.frames["Doyle"].location.reload();
}
</script>
Any suggestions on how to make this work?
I have a situation where I need to refresh an iframe about every 30 seconds. I have looked through the forums and tried a few things, to no avail.
<iframe id="Doyle" src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php"
width="375" height="560">
</iframe>
<script>
window.setInterval("reloadIFrame();", 3000);
function reloadIFrame() {
document.frames["Doyle"].location.reload();
}
</script>
Any suggestions on how to make this work?
Share Improve this question asked Apr 27, 2017 at 15:14 Tyler TracyTyler Tracy 732 silver badges10 bronze badges 1-
What have you done to determine the root cause? Are you seeing any error output in the browser console? Have you checked to see if the
reloadIFrame
function is running? – Lee Jenkins Commented Apr 27, 2017 at 15:24
2 Answers
Reset to default 2Use following code
<iframe id="Doyle" src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php"
width="375" height="560">
</iframe>
<script>
window.setInterval("reloadIFrame();", 30000);
function reloadIFrame() {
var frameHolder=document.getElementById('Doyle');
frameHolder.src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php"
}
</script>
check working example below
http://plnkr.co/edit/Mre0AgMjh5o7wXl5YvVP?p=preview
an iframe is an element, it is not an object like the window one, and to change its target you just need to update its src attribute, document.getElementById('YOURFRAMEID').src="http://google./";
or something like that
Credits here Change URL in an iframe using javascript
I have a situation where I need to refresh an iframe about every 30 seconds. I have looked through the forums and tried a few things, to no avail.
<iframe id="Doyle" src=".php"
width="375" height="560">
</iframe>
<script>
window.setInterval("reloadIFrame();", 3000);
function reloadIFrame() {
document.frames["Doyle"].location.reload();
}
</script>
Any suggestions on how to make this work?
I have a situation where I need to refresh an iframe about every 30 seconds. I have looked through the forums and tried a few things, to no avail.
<iframe id="Doyle" src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php"
width="375" height="560">
</iframe>
<script>
window.setInterval("reloadIFrame();", 3000);
function reloadIFrame() {
document.frames["Doyle"].location.reload();
}
</script>
Any suggestions on how to make this work?
Share Improve this question asked Apr 27, 2017 at 15:14 Tyler TracyTyler Tracy 732 silver badges10 bronze badges 1-
What have you done to determine the root cause? Are you seeing any error output in the browser console? Have you checked to see if the
reloadIFrame
function is running? – Lee Jenkins Commented Apr 27, 2017 at 15:24
2 Answers
Reset to default 2Use following code
<iframe id="Doyle" src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php"
width="375" height="560">
</iframe>
<script>
window.setInterval("reloadIFrame();", 30000);
function reloadIFrame() {
var frameHolder=document.getElementById('Doyle');
frameHolder.src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php"
}
</script>
check working example below
http://plnkr.co/edit/Mre0AgMjh5o7wXl5YvVP?p=preview
an iframe is an element, it is not an object like the window one, and to change its target you just need to update its src attribute, document.getElementById('YOURFRAMEID').src="http://google./";
or something like that
Credits here Change URL in an iframe using javascript
本文标签: javascriptneed an iframe to refresh automaticallyStack Overflow
版权声明:本文标题:javascript - need an iframe to refresh automatically - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745513675a2153940.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论