繁体   English   中英

使用ajax在iframe中加载内容

[英]load content inside iframe using ajax

我有在服务器端工作的iframe:

<iframe frameborder="0" runat="server" style="width: 100%; height: 700px; background-color: #bacad3;" id="I1" name="I1" src="Page.aspx"></iframe>

并使用以下代码动态更改内容:

protected void Button1_Click(object sender, EventArgs e)
{       
   I1.Attributes["src"] = "Page.aspx";
}

我想用以下方式用ajax实现它:

  1. 当用户点击iframe一侧不回发页面并更改iframe的src时
  2. 我想在progressupdatepanel中显示进度

我提到它我不想运行任何回发只是通过调用iframe以外的方式在iframe中加载页面,例如在页面中有一个按钮,它由更新面板处理并加载iframe中其他页面的内容。 有人能帮助我吗?

使用onClientClick和mmke确保返回false以取消回发。

window.frames["frameName"].src = "http://example.com";
//or
document.getElementById("iframeId").src = "http://example.com";

如果您使用的是runat = server,则可能需要使用客户端ID

document.getElementById("<%= iframeId.ClientID %>").src = "http://example.com";

我发现不可能使用这种方法你无法删除回发它需要像google mail(gmail)这样的代理方法当你点击收件箱时它在右边没有回发但我们无法用这种方法实现。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM