Javascript
varBrowserversion =window.navigator.userAgent.toUpperCase ();varIsopera = Browserversion.indexof ("OPERA") >-1?true:false;varIsfirefox = Browserversion.indexof ("FIREFOX") >-1?true:false;varIschrome = Browserversion.indexof ("CHROME") >-1?true:false;varIssafari = Browserversion.indexof ("SAFARI") >-1?true:false;varIsie = (!! Window. ActiveXObject | | "ActiveXObject"inchwindow);varIsie9more = (!-[1,] = =false);functionreinitiframe (Iframeid, minheight) {Try { variframe =document.getElementById (Iframeid); varBheight = 0; if(Ischrome = =false&& Issafari = =false) Bheight=Iframe.contentWindow.document.body.scrollHeight; varDheight = 0; if(Isfirefox = =true) Dheight= Iframe.contentWindow.document.documentElement.offsetHeight + 2; Else if(Isie = =false&& Isopera = =false) Dheight=Iframe.contentWindow.document.documentElement.scrollHeight; Else if(Isie = =true&& Isie9more) {//ie9+ varHeightdeviation = Bheight-eval ("window. Ie9morerealheight "+Iframeid); if(Heightdeviation = = 0) {Bheight+ = 3; } Else if(Heightdeviation! = 3) {eval ("Window. Ie9morerealheight "+ Iframeid +" = "+bheight); Bheight+ = 3; } }Else//ie[6-8], OPERABheight + = 3; varHeight =Math.max (Bheight, dheight); if(Height < minheight) Height =MinHeight; Iframe.style.height= height + "px"; } Catch(ex) {}}functionStartinit (Iframeid, minheight) {eval ("Window. Ie9morerealheight "+ iframeid +" = 0 "); Window.setinterval ("Reinitiframe ('" + Iframeid + "'," + MinHeight + ")", 100);}varMinHeight =$ (window). Height (); Startinit (' Contents ', minheight);
There is a problem to be solved: To remove the value of left and right padding
An IFRAME in HTML dynamically modifies height based on the content of a child page