读书人

iframe的属性:document跟Document以及

发布时间: 2012-06-30 17:20:13 作者: rapoo

iframe的属性:document和Document以及Document的属性和iframe在各个浏览器获得内部文档的写法
.document引用到是的 iframe所在页面对象,
.Document (大写D),才能引用到iframe内含对象

>
test.html

下面是兼容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的属性还有
引用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

读书人网 >移动开发

热点推荐