I am trying to set the height of an iframe dynamically using javascript and Jquery.
But for reason this is not working in Ie8 & chrome. (But its working fine on firefox)
can some body please help?
Thanks
function resizePanel() {
window.console.log("ran the resize panel function");
var frame = document.getElementsByTagName('iframe')[0];
if(frame != null) {
var height;
if(self.innerHeight) {
window.console.log("ran the self.innerHeight");
height= self.innerHeight;
}
else if (document.documentElement && (document.documentElement.clientHeight)) {
window.console.log("ran the clientHeight");
height = document.documentElement.clientHeight;
}
else if(document.body) {
window.console.log("ran the document.body");
height = document.body.clientHeight;
}
frame.style.height = height - 165 + 'px'
}};
$(document).ready(function() {
resizePanel();
$(window).resize(function() {
resizePanel();
});
});
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(EndRequest);
function EndRequest(sender, args) {
resizePanel();
}
The Code works fine on all browsers by changing one line.
Instead of using
use
The problem was Chrome and IE have hidden Iframes and when we use getElementsByTagName it returns us the array of all iframes. so we try to access [0] index, it was referring to some other iframe.
I hope this will help.
The complete code is: