I had a site running on Joomla which was working perfectly before IE9. It still works perfectly but only in compatibility mode.
The problem is in the Javascript function which I used earlier to call an Iframe (this basically has 4 input forms which are loaded one after the other, different sizes) but now its showing an error. I've tried searching forums and on Google but couldn't find a solution. The error is in this line:
h = document.frames('blockrandom').document.body.scrollHeight;
generated by IE9 开发者_JS百科(error code 5002, at character 3rd). Are there any alternatives?
function iFrameHeight() {
var h = 0;
if ( !document.all ) {
h = document.getElementById('blockrandom').contentDocument.height;
document.getElementById('blockrandom').style.height = h + 60 + 'px';
}
else if ( document.all ) {
h = document.frames('blockrandom').document.body.scrollHeight;
document.all.blockrandom.style.height = h + 20 + 'px';
}
}
There are better ways to achieve this without relying on document.frames
or document.all
. Have a look at this short tutorial by Matt Cutts. After reading that, you should end up with something like the following:
var iframe = document.getElementById('blockrandom');
iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
精彩评论