使用WordPress 3.5刷新IFrame

时间:2012-12-18 08:07:42

标签: javascript jquery wordpress wordpress-3.5

使用以前的WordPress版本,我曾使用以下代码自动刷新帖子中的iframe:

<iframe id='feuille1' src="http://competition.hockeyfrance.com/la/ffhgsheet.php?GameID=20094" width="650" height="1000" name='feuille1' ></iframe> 
<script type="text/javascript"> function refreshiframe() { document.getElementById('feuille1').src="http://competition.hockeyfrance.com/la/ffhgsheet.php?GameID=20094" setTimeout("refreshiframe()",30000); } </script> 
<body onload="refreshiframe();">

使用短代码将代码嵌入到帖子中。这很好,直到最近的3.5更新,我理解包括更新版本的jQuery。

有人可以帮助我理解为什么这个非常简单的代码不再起作用了吗?我该怎么做才能解决它?

1 个答案:

答案 0 :(得分:0)

改变这个:

<script type="text/javascript"> function refreshiframe() {document.getElementById('feuille1').src = "http://competition.hockeyfrance.com/la/ffhgsheet.php?GameID=20094"  setTimeout("refreshiframe()",30000); } </script>

要:

<script type="text/javascript"> function refreshiframe() {document.getElementById('feuille1').src = "http://competition.hockeyfrance.com/la/ffhgsheet.php?GameID=20094"; setTimeout("refreshiframe()",30000); } </script>

注意;划分两条不同的js指令,一条用于更改src,另一条用于调用setTimeout函数。

祝你好运!