wid = 'nova';
lang = 'lt';
$(function(){
// Keep track of the iframe height.
var if_height,
// Pass the parent page URL into the Iframe in a meaningful way (this URL could be
// passed via query string or hard coded into the child page, it depends on your needs).
src = 'https://www.novaturas.lt/iframe_site2/'+wid+'/'+lang+'/#' + encodeURIComponent( document.location.href ),
// Append the Iframe into the DOM.
iframe = $( '
.appendTo( '#iframe' );
// Setup a callback to handle the dispatched MessageEvent event. In cases where
// window.postMessage is supported, the passed event will have .data, .origin and
// .source properties. Otherwise, this will only have the .data property.
$.receiveMessage(function(e){
// Get the height from the passsed data.
var h = Number( e.data.replace( /.*if_height=(\d+)(?:&|$)/, '$1' ) );
if ( !isNaN( h ) && h > 0 && h !== if_height ) {
// Height has changed, update the iframe.
iframe.height( if_height = h );
}
// An optional origin URL (Ignored where window.postMessage is unsupported).
}, 'https://www.novaturas.lt' );
});