<iframe id="myframe" name="myframe" width="566px" frameBorder="0" src="" runat="server"></iframe>
iframe 加上runat="server"了,因为我在后台要改变myframe的src,找了很多自适应高度的js但是不能用啊,一般都Onload=jvascript:SetHeight(this), 关键是加了ruant="server" 不能用onload事件了,请教下还有什么办法能使iframe自适应高度?
iframe 加上runat="server"了,因为我在后台要改变myframe的src,找了很多自适应高度的js但是不能用啊,一般都Onload=jvascript:SetHeight(this), 关键是加了ruant="server" 不能用onload事件了,请教下还有什么办法能使iframe自适应高度?
解决方案 »
- 怎样把dataset中的数据插入数据库中既定的表中呢?
- 异常详细信息: System.IndexOutOfRangeException: ChatAdmin怎么解决
- 如何生成静态页
- 我的个人网站,请浏览http://www.138tc.com
- c# Button1_Click如何定义
- >>>求助<<< 如何可以使得无论打开 Web 应用程序中的任何页面,都会执行同一段代码?
- repeater控件绑定了XML数据后,如何定制显示XML数据里的某个元素的值?
- 大菜鸟的我好迷茫!请助大家进来帮我个忙!
- aso.net 中类的继承
- 欢迎测试SQL SERVER+ASP.NET+XML建立的高性能的无刷新聊天程序
- 求asp.net连接odbc的连接
- asp.net 怎样登陆后返回上一页??
把iframe的ID传进去
{
var win=obj;
if (document.getElementById)
{
if (win && !window.opera)
{
if (win.contentDocument && win.contentDocument.body.offsetHeight) win.height = win.contentDocument.body.offsetHeight;
else if(win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight+100;
}
}
}
就这样的时候可以,然后我改了不用onload,把js代码放到iframe下面去也不行...试了半天了就不行..
function SetCwinHeight()
{
try{
var bobo=document.getElementById("ifram123"); //iframe id
if (document.getElementById)
{
if (bobo && !window.opera)
{
if (bobo.contentDocument && bobo.contentDocument.documentElement.offsetHeight)
{
bobo.height = bobo.contentDocument.documentElement.offsetHeight+40;
}
else if(bobo.Document && bobo.Document.body.scrollHeight)
{
bobo.height = bobo.Document.body.scrollHeight+40;//40是空白,可根据需要自己改
}
}
}
}catch(err)
{}
}
</script>
<iframe id="ifram123" scrolling="no" height="500" src="default.aspx" onload="SetCwinHeight()" width="100%" style="border:0px; " frameborder="0">
</iframe>
iframe 这个没必要加 RUNAT=“SERVER ”吧
我要在后台改iframe的src啊....
{
if (Request["frame"] == null)
{
myframe.Attributes.Add("src", "Default.aspx");
}
else
{
string src = Request["frame"].ToString();
myframe.Attributes.Add("src", src);
}
}
function SetCwinHeight()
{
try{
var bobo=document.getElementById("ifram123"); //iframe id
if (document.getElementById)
{
if (bobo && !window.opera)
{
if (bobo.contentDocument && bobo.contentDocument.documentElement.offsetHeight)
{
bobo.height = bobo.contentDocument.documentElement.offsetHeight+40;
}
else if(bobo.Document && bobo.Document.body.scrollHeight)
{
bobo.height = bobo.Document.body.scrollHeight+40;//40是空白,可根据需要自己改
}
}
}
}catch(err)
{}
}
</script>
<iframe id="ifram123" scrolling="no" height="500" src="<%= getsrc()%>" onload="SetCwinHeight()" width="100%" style="border:0px; " frameborder="0">
</iframe> CS文件 里写方法public string getsrc()
{string result="";
if (Request["frame"] == null)
{
result="Default.aspx";
}
else
{
result= Request["frame"].ToString();
}
return result;}