当前位置:网站首页>iframe标签属性说明 详解[通俗易懂]
iframe标签属性说明 详解[通俗易懂]
2022-08-01 12:46:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
Iframe 标签详解<Iframe src=”example.htm” width=”300″ heitht=”100″></IFRAME> example.htm 是被嵌入的页面,标签 <IFRAME> 还有一些可用的参数设置如下: marginwidth:网页中内容在表格右侧的预留宽度;例如:marginwidth=”20″,单位是 pix,下同。 marginheight:网页中内容在表格顶部预留的高度; hspace:网页右上角的的横坐标; vspace:网页右上角的纵坐标; frameborder:是否显示边缘;填”1″表示”是”,填”0″表示”否” scrolling:是否出现滚动条;填”1″表示”是”,填”0″表示”否” 在HTM(HTML)文件中是否可以像PHP、ASP文件一样嵌入其他文件呢?下面笔者介绍用iframe来实现的方法。 iframe元素的功能是在一个文档里内嵌一个文档,创建一个浮动的帧。其部分属性简介如下: name:内嵌帧名称 width:内嵌帧宽度(可用像素值或百分比) height:内嵌帧高度(可用像素值或百分比) frameborder:内嵌帧边框 marginwidth:帧内文本的左右页边距 marginheight:帧内文本的上下页边距 scrolling:是否出现滚动条(“auto”为自动,“yes”为显示,“no”为不显示) src:内嵌入文件的地址 style:内嵌文档的样式(如设置文档背景等) allowtransparency:是否允许透明 明白了以上属性后,我们可用以下代码实现,在main.htm中把samper.htm文件的内容显示在一个高度为80、宽度为100%、自动显示边框的内嵌帧中 让iframe自动适应内容的高度
js代码:
<script>
function autoResize()
{
try
{
document.all["inner"].style.height=inner.document.body.scrollHeight
}
catch(e){}
}
</script>html代码:
<iframe name="inner" src="/ads/?ad=google&ad2=biz2008" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" width="100%" style="height:expression(1); aho:expression(autoResize())"></iframe>自动适应高度的代码 又找到一个好的
代码:
<script type=text/javascript>
<!--
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion>=0.1? 16 : 0
function dyniframesize(down) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(down);
}
else{
eval('pTar = ' + down + ';');
}
if (pTar && !window.opera){
//begin resizing iframe
pTar.style.display="block"
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight;
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
}
}
}
-->
</script>
</HEAD>
<body οnmοusemοve="closesubnav(event);">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<uc1:Admin_header id="Admin_header1" runat="server"></uc1:Admin_header></FONT>
<div id="pagecell1" >
<iframe name="down" width="100%" frameborder="0" src="introduction.aspx" scrolling="no" id="down" οnlοad="javascript:dyniframesize('down');"
/>
</div>
</form>
</body>
</HTML> 发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/126514.html原文链接:https://javaforall.cn
边栏推荐
- shell 中的 分发系统 expect脚本 (传递参数、自动同步文件、指定host和要传输的文件、(构建文件分发系统)(命令批量执行))
- SQL函数 %SQLSTRING
- formatdatetime函数 mysql(date sub函数)
- Meshlab & Open3D SOR filtering
- Software designer test center summary (interior designer personal summary)
- ECCV22|只能11%的参数就能优于Swin,微软提出快速预训练蒸馏方法TinyViT
- 快速幂---学习笔记
- CloudCompare & PCL ICP registration (point to face)
- win10系统重装,无法登录进行同步的情况下chrome数据恢复
- 深入解析volatile关键字
猜你喜欢
随机推荐
.NET性能优化-使用SourceGenerator-Logger记录日志
Complete Raiders of JS Data Type Conversion
Grafana9.0发布,Prometheus和Loki查询生成器、全新导航、热图面板等新功能!
关于亚马逊测评,你了解多少?
如何成功通过 CKA 考试?
uniapp读取和写入文件
windows IDEA + PHP+xdebug 断点调试
Istio Meetup China:全栈服务网格 - Aeraki 助你在 Istio 服务网格中管理任何七层流量
[5 days countdown] to explore the secret behind the great quality promotion, gift waiting for you to take of $one thousand
蔚来又一新品牌披露:产品价格低于20万
Do wildcard SSL certificates not support multiple domains?
大中型网站列表页翻页过多怎么优化?
MySQL调优
How to use DevExpress controls to draw flowcharts?After reading this article, you will understand!
How to successfully pass the CKA exam?
批量替换Word中的表格为图片并保存
这项工作事关中小学生生命安全!五部门作出联合部署
库函数的模拟实现(strlen)(strcpy)(strcat)(strcmp)(strstr)(memcpy)(memmove)(C语言)(VS)
How to integrate 3rd party service center registration into Istio?
人像分割技术解析与应用









