iframe 属性(html iframe如何设置高度和宽度)

本文目录
- html iframe如何设置高度和宽度
- 如何获取页面中iframe的属性
- 如何设置iframe的高度等于内容
- iframe 属性
- 怎么用js来设置这个iframe属性谢谢啦
- js如何修改iframe 中元素的属性
- iframe的visibility属性有哪些
html iframe如何设置高度和宽度
一、iframe 元素会创建包含另外一个文档的内联框架(即行内框架)。
二、有以下方式对iframe进行设置高度和宽度
1、iframe元素标签可以使用width和height属性,
《iframe src ="/index.html" width="400" height="300"》《/iframe》
2、可以使用css来定义宽度和高度
《iframe src ="/index.html" style="width:400px;height:300px"》《/iframe》
三、补充:
iframe的属性如下:
如何获取页面中iframe的属性
给iframe设个id= testIframe
var parentWindow;
var testIframe;
for(var i = 0 ; i 《 10; i++){
parentWindow = window.top.frames;
testIframe= $(’#testIframe’, parentWindow.document).val();
if(testIframe){
break;
}
}
如何设置iframe的高度等于内容
一、iframe 元素会创建包含另外一个文档的内联框架(即行内框架)。
二、有以下方式对iframe进行设置高度和宽度
1、iframe元素标签可以使用width和height属性,
《iframe src ="/index.html" width="400" height="300"》《/iframe》
2、可以使用css来定义宽度和高度
《iframe src ="/index.html" style="width:400px;height:300px"》《/iframe》
三、补充:
iframe的属性如下:
iframe 属性
iframe元素的功能是在一个html内嵌一个文档,创建一个浮动的帧。iframe可以嵌在网页中的任意部分
name:内嵌帧名称
width:内嵌帧宽度(可用像素值或百分比)
height:内嵌帧高度(可用像素值或百分比)
frameborder:内嵌帧边框
marginwidth:帧内文本的左右页边距
marginheight:帧内文本的上下页边距
scrolling:是否出现滚动条(“auto”为自动,“yes”为显示,“no”为不显示)
src:内嵌入文件的地址
style:内嵌文档的样式(如设置文档背景等)
allowtransparency:是否允许透明
iframe还有一个很有用的用法:强调页面的某项内容
先把要强调显示的内容另存为一个文件,如first.htm,然后通过一个预载页index.htm,内容如下:
〈meta
怎么用js来设置这个iframe属性谢谢啦
《!DOCTYPE HTML》
《html》
《head》
《meta charset="UTF-8" /》
《title》last.html《/title》
《style》
《/style》
《script type="text/javascript"》
window.onload = function ()
{
var iframe = document.createElement (’iframe’);
iframe.src = "index.html";
iframe.setAttribute("scrolling", "no");
iframe.setAttribute("frameborder", 0);
iframe.style.position = "fixed";
iframe.style.bottom = 0;
iframe.style.right = 0;
iframe.style.width = "305px";
iframe.style.height = "320px";
document.body.appendChild (iframe);
}
《/script》
《/head》
《body》
《/body》
《/html》
js如何修改iframe 中元素的属性
网页加载的时候,iframe里面的还没加载完当然就更改不了。
1.纯js的
《!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"》
《html xmlns="http://www.w3.org/1999/xhtml"》
《head》
《meta http-equiv="Content-Type" content="text/html; charset=utf-8" /》
《title》无标题文档《/title》
《script language="javascript"》
function c(){
var a;
try{
if (document.all){
a = document.frames.document;
}else{
a = document.getElementById("a").contentDocument;
}
var b = a.getElementsByName("b");
b.disabled = true;
clearInterval(d);
}
catch(ex){
}
}
《/script》
《/head》
《body》
《iframe id="a" src="b.html" onload="c();"》《/iframe》
《/body》
《/html》
2.使用jQuery框架的,建议使用,封装了js,操作DOM等等非常方便
《!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"》
《html xmlns="http://www.w3.org/1999/xhtml"》
《head》
《meta http-equiv="Content-Type" content="text/html; charset=utf-8" /》
《title》无标题文档《/title》
《script language="javascript" src="/js/jquery-1.4.4.js" type="text/javascript"》《/script》
《script language="javascript" type="text/javascript"》
《!--//
$(document).ready(function(){
if ($.browser.msie){
$(’#a’).ready(function(){
$(window.frames.document).find("input").attr("disabled","disabled");
});
}
else{
$(’#a’).load(function(){
$(’#a’).contents().find("input").attr("disabled","disabled");
});
}
});
//--》
《/script》
《/head》
《body》
《iframe id="a" name="a" src="iframechild.html"》《/iframe》
《/body》
《/html》
b.html
《!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"》
《html xmlns="http://www.w3.org/1999/xhtml"》
《head》
《meta http-equiv="Content-Type" content="text/html; charset=utf-8" /》
《title》无标题文档《/title》
《/head》
《body》
《form name="cform"》《input type="text" name="b" /》《/form》
《/body》
《/html》
iframe的visibility属性有哪些
属性 值 描述 DTD
align left
right
top
middle
bottom
不赞成使用。请使用样式代替。
规定如何根据周围的元素来对齐此框架。
TF
frameborder 1
0
规定是否显示框架周围的边框。 TF
height pixels
%
规定 iframe 的高度。 TF
longdesc URL 规定一个页面,该页面包含了有关 iframe 的较长描述。 TF
marginheight pixels 定义 iframe 的顶部和底部的边距。 TF
marginwidth pixels 定义 iframe 的左侧和右侧的边距。 TF
name frame_name 规定 iframe 的名称。 TF
scrolling yes
no
auto
规定是否在 iframe 中显示滚动条。 TF
src URL 规定在 iframe 中显示的文档的 URL。 TF
width pixels
%
定义 iframe 的宽度。 TF

本文相关文章:
我电脑桌面总是跟随着鼠标上下移动,怎么设置?异星探险家视角怎么跟随鼠标
2025年7月22日 22:30
马林巴琴铃声(iphone马林巴琴变奏版下载怎么设置成铃声)
2025年7月22日 09:45
中国电信10000管家(安装中国电信10000管家后如何设置WIFI)
2025年7月19日 21:00
招行超级银行限额怎么更改设置?农行转农行,手机银行或网上银行手续费多少另外怎么开通超级银行,即他行可管理农行的钱,包括实时转账
2025年7月19日 19:00
prey怎么设置中文epic(掠食怎么设置中文 Prey中文语言设置方法)
2025年7月15日 05:45
更多文章:
腾讯手机管家极速版(腾讯网卡免流量和不免流量的软件先用哪一个了)
2025年8月20日 06:00
360杀毒升级包下载(360杀毒软件升级包是什么 还需要用杀毒软件吗)
2025年5月5日 08:50
梦幻诛仙宝宝(梦幻诛仙手游宝宝怎么打书 4+4宝宝顶书技巧)
2025年6月11日 03:10
80后十大经典网络游戏(80后最受欢迎的十大PC游戏,你认识是什么)
2026年9月17日 05:10
app国家医保服务平台下载(国家医保服务平台app怎么下载)
2026年9月28日 05:30
快用ios下载(为什么我用苹果快用下载的应用老是会闪退有的又不会救助)
2026年1月8日 14:30
为什么ie打开是360(怎么打开IE浏览器为什么打开还是360浏览器,谷歌浏览器)
2025年12月5日 06:30












