iframe的属性:document和Document以及Document的属性和iframe在各个浏览器获得内部文档的写法...

.document引用到是的 iframe所在页面对象,
.Document (大写D),才能引用到iframe内含对象
<html>
<head>
<script>
function SetCwinHeight(obj)
{
// alert(obj.document.getElementById("tDiv").innerText);//可以获得当前页面id为tDiv的div的值
alert(obj.Document.all.tDiv.innerText);
//这个可以获得text.html里面id为tDiv的div的值、、、
}
</script>
</head>
<body>
<iframe src="test.html" onload="SetCwinHeight(this);" width="600px' id="myframe"
name="myframe">
</iframe>
<div id="tDiv">
tdiv
</div>
</body>
</html
>
test.html

...
<div id="tDiv" name="tDiv">sdiv</div>
...

下面是兼容ie,ff。chome等的写法

function SetCwinHeight()
{
var obj=document.getElementsByTagName("iframe")[0];
// var obj2=document.getElementById("myframe");//chome和firefox不支持id取iframe
//alert(obj2);
var str="";
var cwin=obj;
var sobj=null;
if (document.getElementById){
if (cwin && !window.opera){
if (cwin.contentDocument){
sobj = cwin.contentDocument; //FF NS
alert("ff or chome");
}
else if(cwin.Document){
sobj = cwin.Document;//IE
alert("ie");
}
}
else{
if(cwin.contentWindow.document){
sobj = cwin.contentWindow.document;//Opera
alert("opera ");
}

}
}
for(i in sobj){
str+=i+"<br/>";
}
document.write(str);

}


另外iframe.Doucment的属性还有
[quote]namespaces
lastModified
parentNode
nodeType
fileCreatedDate
onbeforeeditfocus
bgColor
oncontextmenu
onrowexit
embeds
scripts
onactivate
mimeType
alinkColor
onmousemove
onselectstart
oncontrolselect
body
protocol
onkeypress
onrowenter
onmousedown
vlinkColor
URL
onreadystatechange
doctype
onbeforedeactivate
applets
fileModifiedDate
onmouseover
dir
media
defaultCharset
firstChild
plugins
onafterupdate
ondragstart
oncellchange
cookie
documentElement
nextSibling
nameProp
referrer
ondatasetcomplete
onmousewheel
onerrorupdate
onselectionchange
lastChild
ondblclick
onkeyup
location
forms
title
onrowsinserted
previousSibling
compatMode
onmouseup
onkeydown
onrowsdelete
onfocusout
fgColor
ondatasetchanged
onmouseout
parentWindow
nodeName
onpropertychange
onstop
onhelp
linkColor
onbeforeactivate
images
readyState
frames
all
onbeforeupdate
onclick
childNodes
onfocusin
anchors
selection
fileUpdatedDate
domain
security
fileSize
ownerDocument
ondataavailable
styleSheets
nodeValue
attributes
activeElement
implementation
links
URLUnencoded
ondeactivate
[/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值