My project has 3 files,
File1 has included master page.
file1 consists of iframe1 that load file2.
File2 consists of iframe2 that load file3.
Javascript used on each file to resize the iframe height based on the each iframe's content height.
It is work well on IE, but the error "has no properties" occured with firefox on code as below. Where both code is to get the id of iframe on file1.
parent.document .getElementById ("file1iFrame") .height
self.parent.par ent.document.ge tElementById('f ile1iFrame')
I create another file0 which without master page, it work well on firefox to resize iframe.
So anyone has any idea of what the code suppose to use to get the ID of iframe on file1?
My original code as below which on file1.
CALL JAVASCRIPT:
JAVASCRIPT FUNCTION:
CODE ON file2:
CALL JAVASCRIPT:
CODE ON file3
File1 has included master page.
file1 consists of iframe1 that load file2.
File2 consists of iframe2 that load file3.
Javascript used on each file to resize the iframe height based on the each iframe's content height.
It is work well on IE, but the error "has no properties" occured with firefox on code as below. Where both code is to get the id of iframe on file1.
parent.document .getElementById ("file1iFrame") .height
self.parent.par ent.document.ge tElementById('f ile1iFrame')
I create another file0 which without master page, it work well on firefox to resize iframe.
So anyone has any idea of what the code suppose to use to get the ID of iframe on file1?
My original code as below which on file1.
CALL JAVASCRIPT:
Code:
file1iFrame.Attributes.Add("onload", "size_iframe('file1iFrame')")
Code:
function size_iframe(id){
var newheight;
if(document.getElementById){
if(navigator.userAgent.indexOf("MSIE")!=-1){
newheight=document.getElementById(id).contentWindow.document.body.scrollHeight;
}
if(navigator.userAgent.indexOf("Firefox")!=-1){
newheight=document.getElementById(id).contentDocument.body.scrollHeight;
}
}
if(navigator.userAgent.indexOf("MSIE")!=-1){
document.getElementById(id).style.height= (newheight+10) + "px";
}
if(navigator.userAgent.indexOf("Firefox")!=-1){
document.getElementById(id).height= (newheight+10) + "px";
}
}
CALL JAVASCRIPT:
Code:
file1iFrame.Attributes.Add("onload", "size_iframe('file2iFrame')")
Code:
<body onload="autoParentIframe()">
Code:
function autoParentIframe(){
var x = 0;
var y = this.document.body.scrollHeight;
while (x < y){
x+=1;
}
///////////// reset iframe size for Opera //////////////
if(navigator.userAgent.indexOf("Opera")!=-1){
parent.document.body.scrollHeight = x;
}
/////////////////////IE(5.5+), Opera///////////////////////////////
if(navigator.userAgent.indexOf("MSIE")!=-1){
parent.document.getElementById("file1iFrame").style.height = x;
}
///////////////////// Firefox //////////////////////////////
if(navigator.userAgent.indexOf("Firefox")!=-1){
parent.document.getElementById("file1iFrame").height = x;
}
}
Code:
<body onload="reloadparent()">
function reloadparent()
{
autoResizeObject(self.parent.document.getElementById('file2iFrame'));
autoResizeObject(self.parent.parent.document.getElementById('file1iFrame'));
}
function autoResizeObject(obj)
{
var newheight;
var newwidth;
if(document.getElementById){
if(navigator.userAgent.indexOf("MSIE")!=-1){
newheight=obj.contentWindow.document.body.scrollHeight;
}
if(navigator.userAgent.indexOf("Firefox")!=-1){
newheight=obj.contentDocument.body.scrollHeight;
}
}
obj.style.height= (newheight+10) + "px";
}
Comment