1 html javascript iframe refresh reload
想知道如何每x秒重新加载一个iframe,最好不要使用javascript.
谢谢.
cdh*_*wie 13
使用Refresh: x
HTTP标头或文档中的HTML元素加载到iframe中:
<meta http-equiv="refresh" content="x" />
Run Code Online (Sandbox Code Playgroud)
此元素应放在文档<head/>
元素的内部.
如果您无法控制加载到框架中的文档或服务它的服务器,您有两种选择:
<meta/>
元素编写另一个HTML页面,并在该页面中包含一个iframe,以定位另一个页面.所以你在iframe中会有一个iframe:外部文档 - > iframe(带有元刷新的内部文档) - > iframe(原始iframe目标)编辑:关于选项#2,这里是PHP中一个不错的通用iframe,它在刷新时间和样式方面提供了一些灵活性.只需用以下内容调用它:
http://www.mydomain.com/genericIframe.php?url=http://my.domain.com/mypage.htm&refreshTime=60&style=putYourStyleAttribHere
这是PHP/HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Generic Iframe</title>
<meta http-equiv="refresh" content="<?php print $_REQUEST['refreshTime']; ?>" />
</head>
<body>
<iframe src="<?php print $_REQUEST['url']; ?>" style="<?php print $_REQUEST['style']; ?>"></iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)