Get child iframe
Contentwindow all browsers support chrome to a server environment to
Contentdocument IE 6 7 not supported
document.getElementById (' iframe_id '). ContentWindow.document.getElementById (' child page element node ');
Window.parent Child Frame Action Parent page
Window.parent.document.getElementById (' parent page element node '). style.csstext=.
Window.top Get top Level page
Window.top.document.getElementById (' topmost page element node '). style.csstext=.
Prevent being nested:
if (window!=window.top) {
Window.top.location.href=window.location.href
}
--------------------------------------------------------------------------------------------------------------- ---
IFrame Adaptive height and width:
function Iframeresize (iframename) {
var Ptar = document.getElementById (iframename);
if (Ptar) {//FF
if (ptar.contentdocument && pTar.contentDocument.body.offsetHeight) {
Ptar.height = PTar.contentDocument.body.offsetHeight;
}//ie
else if (ptar.document && pTar.Document.body.scrollHeight) {
Ptar.height = PTar.Document.body.scrollHeight;
}
}
}
IFrame width Adaptive
function Iframeresizewidth (iframename) {
var Ptar = document.getElementById (iframename);
if (Ptar) {//FF
if (ptar.contentdocument && pTar.contentDocument.body.offsetWidth) {
Ptar.width = PTar.contentDocument.body.offsetWidth;
}//ie
else if (ptar.document && pTar.Document.body.scrollWidth) {
Ptar.width = PTar.Document.body.scrollWidth;
}
}
}
Here's how to use it:
<iframe src= "main.aspx" scrolling= "no" frameborder= "0" height= "100%" id= "MainFrame" width= "100%" onload= ' Iframeresize ("MainFrame"); Iframeresizewidth ("MainFrame"); ></iframe>
Manipulating an IFrame