2017-09-14 70 views
0

我在ASP.NET网站中有一个页面。 iframe位于Ajax更新面板中。更改iframe src而无需刷新父页面

我有一个需要从javascript,我可以做改变的iframe src属性。问题是当src属性更改时,父页面会刷新。

我只需要有框架导航,不是父页面。

HTML:

 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
      <ContentTemplate> 
       <iframe id="previewIframe" runat="server" Width="800px"></iframe> 
      </ContentTemplate>    
     </asp:UpdatePanel> 

的javascript:

var frame = $("#previewIframe"); 
frame.setAttribute('src', "http://www.google.com"); 
+0

是当其实际产生的实际调用previewIframe框架?或者ASP.NET是否将其控制名称预先设置为它? – Steve

+0

另外在jQuery中它应该是:$(“#previewIframe”)。attr('src',“http://www.google.com”),setAttribute用于javascript DOM。 – Steve

+0

我为iframe添加了ClientIDMode =“Static”并刷新了