Adapt size of iframe dependent of other div

From wiki.network-crawler.de
Jump to: navigation, search

Java part


window.addEventListener('resize', event_handler, false);
window.addEventListener('load', event_handler, false);

function event_handler()
{
    var newheight;
    var newwidth;

    var id =  "bbs_maps_adjust";
	
    if(document.getElementById){
        newheight=jQuery('#content').height();
        newwidth=jQuery('#content').width();
    }

    document.getElementById(id).height= (newheight) + "px";
    document.getElementById(id).width= (newwidth) + "px";

}

/* ---------------------------------------------------------------------
  Adjust Google Maps IFrame
----------------------------------------------------------------------*/


function autoResize(id){
    var newheight;
    var newwidth;

    if(document.getElementById){
        newheight=jQuery('#content').height();
        newwidth=jQuery('#content').width();
    }

    document.getElementById(id).height= (newheight) + "px";
    document.getElementById(id).width= (newwidth) + "px";
}

html part

<div id="bbs_maps">
         <iframe
	 src="http://2bsolutions.de"
	 width="800" height="600" frameborder="0" style="border:0" id="bbs_maps_adjust" onLoad="autoResize(\'bbs_maps_adjust\');">
         </iframe>
</div>