社区
ASP
帖子详情
100分求解:如何使跨站调用的框架自适应高度!
alanxua
2006-02-17 06:55:36
如何使跨站调用的框架自适应高度?公司有两个网站,有不同的域名,要在一个网站中用框架调用另一个站点的内容,并且使框架高度自适应(能够随着页面的长度变化自动的适应以免页面和iframe同时出现滚动条),在网上查到很多代码,但只有被框架调用的页面在同一个站点下才有效,否则会提示没有权限或只显示一部分内容,请问要在一个站点下用框架调用另一个站点的页面,并自适应高度,该如何实现?谁有有效的代码?
...全文
662
13
打赏
收藏
100分求解:如何使跨站调用的框架自适应高度!
如何使跨站调用的框架自适应高度?公司有两个网站,有不同的域名,要在一个网站中用框架调用另一个站点的内容,并且使框架高度自适应(能够随着页面的长度变化自动的适应以免页面和iframe同时出现滚动条),在网上查到很多代码,但只有被框架调用的页面在同一个站点下才有效,否则会提示没有权限或只显示一部分内容,请问要在一个站点下用框架调用另一个站点的页面,并自适应高度,该如何实现?谁有有效的代码?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
13 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
goodstuday
2006-06-01
打赏
举报
回复
1.htm的代码:
<iframe src=2.htm id=ifrm></iframe>
2.htm的代码:
<script>
function resize()
{parent.document.all.ifrm.height=document.body.scrollHeight;}
</script>
<body onload="resize()">
</body>
--------------------------------------------------
同站点下可以,为什么不同站点就不行了,有没有解决方法?
harryCom
2006-06-01
打赏
举报
回复
以上的方法都不行吧,只要是不同的域,涉及到互相访问document都会提示没有权限
net205
2006-06-01
打赏
举报
回复
晕,刚才试了下,好像是不行滴。没撤吧。。。
<iframe src=http://www.csdn.net id=ifrm onload="document.all.ifrm.height=this.contentWindow.document.body.scrollHeight"></iframe>
net205
2006-06-01
打赏
举报
回复
主要是parent.document.all.ifrm.height=document.body.scrollHeight
如果在套别的网站那像狼一样在iframe属的onload里加加...
超级大笨狼
2006-02-17
打赏
举报
回复
实验下吧,不知道哪个好使。
到superdullwolf.cnzone.net下载笨狼代码搜藏集。
常见问题基本都有答案。
超级大笨狼
2006-02-17
打赏
举报
回复
demo.htm
<input type="text" name="ParText">
<input type="button" value="Get" onclick="getValue()">
<iframe src="in.htm" name="in"></iframe>
<script>
function getValue()
{
document.all.ParText.value = top.frames["in"].document.all.SonText.value;
}
</script>
in.htm
<input type="text" name="SonText" value="baobao">
超级大笨狼
2006-02-17
打赏
举报
回复
Iframe 自适应其加载的网页高度(多浏览器兼容版)
A :
如何在打开这个页面时得到这个页面的高度?
一个框架面面,包含三个页面
头,左,右三个页面
右面的页面是主显示区会有滚动条,如何让整个框架页有滚动条,而不是单个页面出滚动条。
---------------------------------------------------------------
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<meta name='author' content='F.R.Huang(meizz梅花雪)//www.meizz.com'>
<title>用 iframe 模拟 frame 使网架网页能够居中</title>
</head>
<body topmargin=0 leftmargin=0><center>
<table border=0 width=780 height=100% cellspacing=0 cellpadding=0 align=center>
<tr><td width=780 colspan=2 height=100>
<iframe width=100% height=100% frameborder=1></iframe>
</td></tr>
<tr>
<td width=180>
<iframe width=100% height=100% frameborder=1></iframe>
</td>
<td width=600 valign=top><div style="height: 100%">
<iframe width=100% height=100% name="MzMain" frameborder=1
id="MzMain" src="用iframe模拟frame子页.htm"></iframe>
</div></td>
</tr>
</table>
</center></body></html>
用iframe模拟frame子页.htm
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<meta name='author' content='F.R.Huang(meizz梅花雪)//www.meizz.com'>
<title>iframe 自适应其加载的网页(多浏览器兼容)</title>
<script language=javascript>
function iframeAutoFit() //author: meizz(梅花雪 20041225)
{
if(self!=top && window.name=="MzMain") //这个 name 对应的是 iframe 的 name
{
var iframe = parent.document.getElementById(window.name);
if(iframe)
{
iframe.parentNode.style.height = iframe.style.height;
iframe.style.height = 10;
var h = document.body.scrollHeight;
var minimalHeight = parseInt((window.screen.width*11)/16, 10) - 280;
h = h<minimalHeight ? minimalHeight : h;
if(window.navigator.appName == "Microsoft Internet Explorer"
&& iframe.frameBorder=="1") h += 4;
iframe.parentNode.style.height = iframe.style.height = h;
}
else alert("Iframe's id unequal to iframe's name!");
}
}
if(document.attachEvent) window.attachEvent("onload", iframeAutoFit);
else window.addEventListener('load', iframeAutoFit, false);
</script>
</head>
<body>
<span style="width: 300; height: 400; background-color: yellow">
iframe 自适应其加载的网页(多浏览器兼容)
</span>
</body>
</html>
超级大笨狼
2006-02-17
打赏
举报
回复
如何在iframe的name不定时,根据被包含页面大小动态改变iframe的大小?
A :
秋水无痕:
<script language="javascript">
function toppage()
{
if (self.location!=top.location)frameElement.height=document.body.scrollHeight + 30;
}
</script>
<body onload="toppage()">
frameElement地用法,可见
http://www.blueidea.com/bbs/newsdetail.asp?id=442170
但frameElement只有在IE5.5以上支持。
根据秋水的提示,我在看了
http://www.blueidea.com/bbs/newsdetail.asp?id=340771
后知道了完美的解决办法。
<script language="javascript">
<!--
function toppage()
{
if (self.location!=top.location)
{
parent.document.all(self.name).height=document.body.scrollHeight + 30;
}
}
-->
</script>
<body onload="toppage()">
IE5.0测试通过,IE4没法试了,不过还用IE4的非常少了,基本可以不考虑。
超级大笨狼
2006-02-17
打赏
举报
回复
如何更改<iframe>的高度?急!在线等,高分!
A :
有这样的代码:
<iframe frameborder="0" scrolling="no" src="body.htm" width="778" height="710" name="m_body"></iframe>
如何在body.htm里改变<iframe>的高度!
---------------------------------------------------------------
<body onload="parent.document.all.m_body.style.height='4000'">
超级大笨狼
2006-02-17
打赏
举报
回复
如果何能使iframe的大小随着它包含的网页里面的table大小变化而变化?急切!!!
A :
例如,怎样使iframe的高度和宽度 随着table的高度和宽度 改变而改变?如下:
Main.htm
<html>
<body>
<div>
<iframe name=mm src=”detail.htm” width=”变数” height=”变数” </iframe>
</div>
</body>
</html>
detail.htm
<html>
<body>
<table width=”变数” height=”变数” border=0 bgcolor=red>
<tr><td></td></tr>
</table>
</body>
</html>
急切,请高手快指点!!!!
---------------------------------------------------------------
main.htm
<html>
<body>
<div>
<iframe id=frmDetail scrolling=no name=mm src="detail.htm" style="width:expression(this.contentWindow.document.all.tblDetail.width);height:expression(this.contentWindow.document.all.tblDetail.height)"></iframe>
<button onclick="with(document.all.frmDetail.contentWindow.document.all.tblDetail){width=offsetWidth+1}">+</button>
<button onclick="with(document.all.frmDetail.contentWindow.document.all.tblDetail){width=offsetWidth-1}">-</button>
</div>
</body>
</html>
detail.htm
<html>
<body leftmargin=0 topmargin=0>
<table id=tblDetail width=100 height=100 border=0 bgcolor=red>
<tr><td></td></tr>
</table>
</body>
</html>
---------------------------------------------------------------
稍微变通一下就是啦.
main.htm
<html>
<body>
<div>
<iframe id=frmDetail scrolling=no name=mm src="tb.htm" onload="style.width=this.contentWindow.document.all.tblDetail.offsetWidth;style.height=this.contentWindow.document.all.tblDetail.offsetHeight"></iframe>
</div>
</body>
</html>
tb.htm
<html>
<body leftmargin=0 topmargin=0>
<table id=tblDetail width=100 height=100 border=0 bgcolor=red>
<tr><td>
dddddddddddddddddddddddddddddddddddddddddddddddddddddddd
</td></tr>
</table>
</body>
</html>
---------------------------------------------------------------
test.asp
<%
url=Request.QueryString("url")
%>
<body onload="document.all.ifId.style.width=parseInt(ifId.document.getElementsByTagName('table')[0].width)+20">
<iframe name=ifId id=ifId src="<%=url%>"></iframe>
<br>
<a href=2.asp?url=1.asp>1.asp</a>
<br>
<a href=2.asp?url=2.asp>2.asp</a>
1.asp
<table width=500>
<tr><td>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</table>
2.asp
<table width=200>
<tr><td>
aaaaaaaaa
</table>
ckl881003
2006-02-17
打赏
举报
回复
宽度设成百分比 <iframe width=100% height=100%>
超级大笨狼
2006-02-17
打赏
举报
回复
怎样通过ifame指向的页面高度调整iframe的高度
A :
怎样通过ifame指向的页面高度调整iframe的高度,这样可以避免iframe的滚动条
---------------------------------------------------------------
<iframe name="ifrm" id="frm" src="yourPage.asp"><iframe>
<button onclick="frm.style.height=document.ifrm.document.body.clientHeight">
让iframe高度适应其内叶面高度</button>
---------------------------------------------------------------
1.htm的代码:
<iframe src=2.htm id=ifrm></iframe>
2.htm的代码:
<script>
function resize()
{parent.document.all.ifrm.height=document.body.scrollHeight;}
</script>
<body onload="resize()">
</body>
liu_zhaoqf
2006-02-17
打赏
举报
回复
你可以将页面的高度和宽度固定阿
自适应
遗传算法matlab源码-awesome-quantum-software:开源量子软件项目策划清单
自适应
遗传算法matlab源码 开源量子软件项目 开源开发的量子软件项目的策划清单。 投稿前请先阅读。 另外,请查看量子OSS的4k $赠款项目! 内容 有关精选的学习资源列表,请查看。 量子全栈库 C ++ -。 -。 Python -...
VC与Labview、Matlab编程论文资料[2].rar
基于LabVIEW和MATLAB混合编程的
自适应
滤波器设计.pdf 基于LabVIEW和Matlab的自动控制虚拟实验系统.pdf 基于Labview和VC的脑机接口系统设计.pdf 基于LabVIEW和单片机的切削温度虚拟仪器的研究.pdf 基于LabVIEW多...
matlab常微
分
方程
求解
matlab常微
分
方程
求解
,通过编程实战掌握具体应用。包括matlab常微
分
方程
求解
前、matlab常微
分
方程
求解
中、matlab常微
分
方程
求解
后。
VC与Labview、Matlab编程论文资料
基于LabVIEW和MATLAB混合编程的
自适应
滤波器设计.pdf 基于LabVIEW和Matlab的自动控制虚拟实验系统.pdf 基于Labview和VC的脑机接口系统设计.pdf 基于LabVIEW和单片机的切削温度虚拟仪器的研究.pdf 基于LabVIEW多...
VC与Labview、Matlab编程论文资料[4].rar
基于LabVIEW和MATLAB混合编程的
自适应
滤波器设计.pdf 基于LabVIEW和Matlab的自动控制虚拟实验系统.pdf 基于Labview和VC的脑机接口系统设计.pdf 基于LabVIEW和单片机的切削温度虚拟仪器的研究.pdf 基于LabVIEW多...
ASP
28,390
社区成员
357,068
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章