当前位置:网站首页>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
边栏推荐
- Aeraki Mesh 正式成为 CNCF 沙箱项目
- 快速幂---学习笔记
- 2022 Go ecosystem rpc framework Benchmark
- 为什么最大值加一等于最小值
- 让程序员早点下班的效率工具
- NebulaGraph v3.2.0 性能报告
- 意大利普拉托华社将游行示威 盼解决安全问题
- Data frame and remote frame of CAN communication
- R language ggplot2 visualization: use ggpubr package ggscatter function visualization scatterplot, use xscale wasn't entirely specified X axis measurement adjustment function, set the X coordinate for
- Alibaba Cloud Official Redis Development Specification
猜你喜欢
随机推荐
Visualization of lag correlation of two time series data in R language: use the ccf function of the forecast package to draw the cross-correlation function, and analyze the lag correlation according t
数字孪生北京故宫,元宇宙推进旅游业进程
How to get the address of WeChat video account (link address of WeChat public account)
Js手写函数之new的模拟实现
How do programmers solve online problems gracefully?
10年稳定性保障经验总结,故障复盘要回答哪三大关键问题?|TakinTalks大咖分享
Aeraki Mesh became CNCF sandbox project
pandas connects to the oracle database and pulls the data in the table into the dataframe, filters all the data from the current time (sysdate) to one hour ago (filters the range data of one hour)
【StoneDB Class】入门第二课:StoneDB 整体架构解析
How to Integrate Your Service Registry with Istio?
【讲座分享】“营收“看金融
MNIST是什么(plist是什么意思)
The four methods of judging JS data type
初级必备:单例模式的7个问题
【公开课预告】:超分辨率技术在视频画质增强领域的研究与应用
LeetCode_位运算_简单_405.数字转换为十六进制数
Simulation implementation of new of Js handwritten function
Dapr 与 NestJs ,实战编写一个 Pub & Sub 装饰器
[Nodejs] fs module of node
通讯录(静态版)(C语言)(VS)








