var __hc = {<br> i: null , // <br> h: 0, // <br> iframes: [ null , null ], // <br> path: 'master.com/height.html#' , // height.html <br> // <br> setHeight: function (height) {<br> var ifr,i;<br> for (i=0;i<2;i++) {<br> if ( this .iframes[i]) this .iframes[i].parentNode.removeChild( this .iframes[i]);<br> ifr = document .createElement( 'IFRAME' );<br> ifr.style.display = 'none' ;<br> this .iframes[i] = ifr;<br> document .body.appendChild( this .iframes[i]);<br> ifr.src = 'http://' + (i ? 'www.' : '' ) + this .path + height;<br> }<br> },<br> // — <br> onLoad: function (full) {<br> this .checkHeight();<br> if (full) {<br> this .i = window.setInterval( this .bind( this .checkHeight), 100);<br> }<br> },<br> // , <br> checkHeight: function () {<br> var h = this .getDocHeight();<br> if ( this .h == h) return ;<br><br> this .h = h;<br> this .setHeight( this .h);<br> },<br> // , <br> getDocHeight: function () {<br> if (window.GetDocumentHeight) return window.GetDocumentHeight();<br> var D = document ;<br> return Math.max(<br> D.body.scrollHeight, D.documentElement.scrollHeight,<br> D.body.offsetHeight, D.documentElement.offsetHeight,<br> D.body.clientHeight, D.documentElement.clientHeight<br> );<br> },<br> // <br> addEvent: function (o, t, h) {<br> if (o.addEventListener) o.addEventListener(t, h, false );<br> else if (o.attachEvent) o.attachEvent( 'on' +t, h);<br> },<br> bind: function (method) {<br> var context = this , args = arguments;<br> return function () {<br> return method.apply(context, Array.prototype.slice.call(args, 1));<br> };<br> },<br> // <br> init: function (full) {<br> this .addEvent(window, 'load' , this .bind( this .onLoad, full));<br> }<br>};<br><br>__hc.init( true ); <br><br> * This source code was highlighted with Source Code Highlighter .
< html >< head > <br> < script type ="text/javascript" > <br> // location.hash – <br> var l = location.hash.replace( '#' , '' );<br> if (l) {<br> // try catch <br> try {<br> parent.parent. document .getElementById( 'iframe' ).style.height = l + 'px' ;<br> } catch (e) {}<br> }<br> </ script > <br> </ head > <br> </ html > <br><br> * This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/78845/