如何实现iframe 刷新

zhouxuegangjava163 2009-10-22 12:06:37
iframe.html

<html>
<head>
<title>实现iframe局部刷新</title>
</head>
<body>
<div id="iframeDiv" style="display:block;position:absolute;left:200px;top:300px;width:200px;height:1000px">
<iframe id="parentIframe" name="parentIframe" src="parentIframe.html" scrolling="yes"></iframe>
</div>
<button name="refresh" onclick="reloads()">实现局部刷新</button>
</body>
</html>
<SCRIPT LANGUAGE="JavaScript">
<!--
function reloads()
{
parentIframe.winodw.location.reload();
}

//-->
</SCRIPT>
parentIframe.html

<html>
<head>
<title>parent Iframe</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
var date = new Date();
document.write(date);
//-->
</SCRIPT>
</body>
</html>

需要注意的是,我试了很多方法 都能刷新,但它也把iframe.html也刷新了,能不能有什么方法实现局部刷新,不能刷新iframe.html,只会刷新parentIframe.html
...全文
208 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
swandragon 2009-10-22
  • 打赏
  • 举报
回复
iframe.html,iframe并没有刷新,只刷新了parentIframe

<html>
<head>
<title>实现iframe局部刷新 </title>
</head>
<body>
<div id="iframeDiv" style="display:block;position:absolute;left:200px;top:300px;width:200px;height:1000px">
<iframe id="parentIframe" name="parentIframe" src="parentIframe.html" scrolling="yes"> </iframe>
</div>
<button name="refresh" onclick="reloads()">实现局部刷新 </button>
</body>
</html>
<SCRIPT LANGUAGE="JavaScript">
<!--
function reloads()
{
document.parentIframe.location.reload();
}
var date = new Date();
document.write(date);
//-->
</SCRIPT>

xiaozejun 2009-10-22
  • 打赏
  • 举报
回复
window.parent.frames["carnoc"].location.reload();
carnoc代表你框架某个部分的名称
BearKin 2009-10-22
  • 打赏
  • 举报
回复
LS可以 或者是重新指定下那个IFRAME的地址

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧