1.用Response.Write("<script>document.frames.myframe.location.href='aa.html';</script>")时
出现 document.frames.myframe.location.href不是对象或为空。错误!2.用document.getElementById('myframe').src='aa.html';时,出现 document.getElementById('myframe').不是对象或为空。错误!到底该怎么在后台找到myframe(iframe的id)对象?罗嗦一句,我要实现效果,点击不同按钮,在iframe里显示不同页面,很简单吧!
出现 document.frames.myframe.location.href不是对象或为空。错误!2.用document.getElementById('myframe').src='aa.html';时,出现 document.getElementById('myframe').不是对象或为空。错误!到底该怎么在后台找到myframe(iframe的id)对象?罗嗦一句,我要实现效果,点击不同按钮,在iframe里显示不同页面,很简单吧!
iframe 里面的src用变量 src=<%=aaa%>然后在后台赋值
protected string aaa
aaa="aa.html";
难道就不能用document...的方法吗?
高人指点啊!
scrolling="no" runat="server" IFRAME>Page_Load
ifrm.Attributes.Add("src", "xxx.aspx?a=1&b=2")
用ifrm.Attributes.Add("src", "xxx.aspx?a=1&b=2")
还是说找不到ifrm,我要问的是,怎么就在后台得不到iframe对象呢?
scrolling="no" runat="server" </IFRAME>CType(Page.FindControl("ifrm"), HtmlGenericControl).Attributes.Add("src", "xxx.aspx?a=1&b=2")
能不能给个c#的?
我的问题是,怎么得到iframe的id值,以便改变src的值,怎么老是报错document.frames.myframe.location.href不是对象或为空!!!!!!!!!!!!!!!!!!!!!!!!很急,高手就帮帮忙吧!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Response.Write("window.open('http://www.yahoo.com.cn','MainFrame','');");
Response.Write("</script>");
'MainFrame'是iframe的id,他怎么是新打开一页显示,而不是嵌在iframe里呢???
<IFRAME id="ifrm" height="100%" width="100%" frameBorder="no" scrolling="no" runat="server">
</IFRAME>在cs的声明部分加入iframe的声明:
protected System.Web.UI.HtmlControls.HtmlGenericControl ifrm;在Page_Load中加入:
ifrm.Attributes["src"]="http://www.google.com";保证好用!
function ShowFrame(st)
{
switch(st)
{
case 1:
document.frames["CenterFrame"].location="Myfile.aspx";
break;
case 2:
document.frames["CenterFrame"].location="Group.aspx";
}
</script>
在后台调用ShowFrame()
换个思路不行吗?非要更改src属性~
直接让myframe那个窗口跳转到你想要显示的页面不就可以了~
我在一国外论坛找到的答案:
<iframe id="MyIFrame"></iframe>then in codebehind after declaring
protected HtmlGenericControl MyIFrame;doing
MyIFrame.Attributes["src"] = Request["srcPage"];Aaron.结贴了!同志们加油啊!