我想在iframe中动态引入文件。

internetibm 2004-03-18 08:42:38
t.htm

<script>
function change(org)
{
if (org.name=="A")
{
document.Myframe.src="A.htm";
}
else
{
document.Myframe.src="B.htm";
}
}
</script>
<input type=button name="A" value="TestA" onclick=change(this);>
<input type=button name="B" value="TestB" onclick=change(this);>
<iframe name=Myframe src=tmp.htm></iframe>

这样写有错误,不知道怎样改!
...全文
60 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wcqgm 2004-03-18
  • 打赏
  • 举报
回复
跟frameset用法差不多。
zhjzh_zjz 2004-03-18
  • 打赏
  • 举报
回复
对于frame和iframe有一个特殊现象,name是指包含在frame里面的网页的window对象。
<script>
function change(org)
{
if (org.name=="A")
{
document.all.Myframe.src="A.htm";//document.Myframe.location.href="A.htm";亦可
}
else
{
document.all.Myframe.src="B.htm";//document.Myframe.location.href="B.htm";亦可
}
}
</script>
<input type=button name="A" value="TestA" onclick=change(this);>
<input type=button name="B" value="TestB" onclick=change(this);>
<iframe name='Myframe' id='Myframe' src=tmp.htm></iframe>




zhjzh_zjz 2004-03-18
  • 打赏
  • 举报
回复
t.htm

//请把frame iframe的名字和id都设为Myframe,然后

<script>
function change(org)
{
if (org.name=="A")
{
document.all.Myframe.src="A.htm";
}
else
{
document.all.Myframe.src="B.htm";
}
}
</script>
<input type=button name="A" value="TestA" onclick=change(this);>
<input type=button name="B" value="TestB" onclick=change(this);>
<iframe name=Myframe src=tmp.htm></iframe>

再看看!
wanghr100 2004-03-18
  • 打赏
  • 举报
回复
or..


<script>
function change(org)
{
if (org.name=="A")
{
document.Myframe.location.href="A.htm";
}
else
{
document.Myframe.location.href="B.htm";
}
}
</script>
<input type=button name="A" value="TestA" onclick=change(this);>
<input type=button name="B" value="TestB" onclick=change(this);>
<iframe name=Myframe src="tmp.htm"></iframe>

不能跨域访问..
wanghr100 2004-03-18
  • 打赏
  • 举报
回复
<script>
function change(org)
{
if (org=="A")
{
document.Myframe.location.href="A.htm";
}
else
{
document.Myframe.location.href="B.htm";
}
}
</script>
<input type=button name="A" value="TestA" onclick=change(this.name);>
<input type=button name="B" value="TestB" onclick=change(this.name);>
<iframe name=Myframe src="tmp.htm"></iframe>

87,910

社区成员

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

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