iframe 刷新求助

meic1985 2012-06-26 03:24:31
一个画面上 一个按钮 一个iframe 点击按钮的时候 刷新iframe,为什么我写的不能实现,总是会把整个画面跳转掉。
求高手...


<html>
<head>
<title>Untitled</title>
</head>
<script type="text/javascript">
function iframe2aa()
{
var frame = document.getElementById("ifame");
frame.document.location = "aa.htm";
}
function iframe2bb()
{
var frame = document.getElementById("ifame");
frame.document.location = "bb.htm";
}
</script>
<body>

<table>
<tr>
<td>
<div id="div1">
<input type="button" value="button_aa" onclick="iframe2aa()">
<input type="button" value="button_bb" onclick="iframe2bb()">
<iframe width="100%" height="450"
src="aa.htm"
frameborder="0" id="ifame"
name="ifame" scrolling="no">
</iframe>
</div>
</td>
</tr>
</table>
</body>
</html>
...全文
136 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zbhfy 2012-06-26
  • 打赏
  • 举报
回复
function iframe2aa()
{
var frame = document.getElementById("ifame");
frame.document.location = "aa.htm";
}
这个函数里面改成
var frame = document.getElementById("ifame").name;
window.open("bb.html",frame);
试试。
zbhfy 2012-06-26
  • 打赏
  • 举报
回复
function iframe2aa()
{
var frame = document.getElementById("ifame");
frame.document.location = "aa.htm";
}
这个函数里面改成
var frame = document.getElementById("ifame").name;
window.open("bb.html",frame);
试试。
基拉 2012-06-26
  • 打赏
  • 举报
回复

<input type="button" name="Button" value="Button"
onclick="document.frames('ifrmname').location.reload()">

OR

<input type="button" name="Button" value="Button"
onclick="document.all.ifrmname.document.location.reload()">

OR
用iframe的id属性定位
<input type="button" name="Button" value="Button"
onclick="ifrmid.window.location.reload()">

woshichu66 2012-06-26
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function iframe2aa()
{
var frame = document.getElementById("ifame");
frame.src = "a.html";
}
function iframe2bb()
{
var frame = document.getElementById("ifame");
frame.src = "b.html";
}
</script>

</head>
<body>
<input type="button" value="button_aa" onclick="iframe2aa()">
<input type="button" value="button_bb" onclick="iframe2bb()">
<iframe width="100%" height="450"
src="a.html"
frameborder="0" id="ifame"
name="ifame" scrolling="no">
</iframe>
</body>
</html>
wei2253498 2012-06-26
  • 打赏
  • 举报
回复
在IE中经常是用“控件ID.属性或方法名”的方式就找不到对应的属性或方法名,换成用“document.getElementById("控件ID").属性或方法名”的方式就可以了
wei2253498 2012-06-26
  • 打赏
  • 举报
回复
<html>
<head>
<title>Untitled</title>
</head>
<script type="text/javascript">
function iframe2aa(u)
{

document.getElementById("ifameid").src = u ;

}
function iframe2bb(u)
{
document.getElementById("ifameid").src = u ;
}
</script>
<body>

<table>
<tr>
<td>

<input type="button" value="button_aa" onclick="iframe2aa('aa.htm')">
<input type="button" value="button_bb" onclick="iframe2bb('bb.htm')">
<iframe width="100%" height="450"
src=""
frameborder="0" id="ifameid"
name="ifame" scrolling="no">
</iframe>
</td>
</tr>
</table>
</body>
</html>

给你改了一下 你看下吧
meic1985 2012-06-26
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

function iframe2aa()
{
var frame = document.getElementById("ifame");
frame.document.location.reload() ;
}
这个
[/Quote]
var frame = document.getElementById("ifame");
frame.src = "bb.htm";
frame.document.location.reload() ;

改成这样,画面没有跳转,但是也没刷新。
wei2253498 2012-06-26
  • 打赏
  • 举报
回复
function iframe2aa()
{
var frame = document.getElementById("ifame");
frame.document.location.reload() ;
}
这个

67,550

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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