javascript resize iframe height

function adjustFrameHeight(frameId){
        try{ 
            var frame = document.getElementById(frameId);
            var frameDoc;
 
            if (frame.contentDocument)
                frameDoc = frame.contentDocument;
            else 
                frameDoc = frame.contentWindow.document;
 
            if (navigator.appName == "Microsoft Internet Explorer"){
                frame.style.height = frameDoc.body.scrollHeight+'px';
            }else{
                frame.style.height = frameDoc.body.offsetHeight+'px';
            }    
         }catch(err){
                //ignore
         }    
}