javascript - Iframe height definition in IE 7 -
i have problem resizing iframe content in ie7. have external iframe
<iframe id=fl_game src="my_iframe_page" frameborder=0 allowtransparency scrolling=no></iframe>
with width=100%, height=93%
and add page it. here page body
<div id="container"> <div id="game-box"> <div id="flashcontent"> </div> </div> </div> <script type="text/javascript"> swfobject.embedswf("<%=application.getcontextpath()%>/flash/<%= request.getparameter(param_game) %>/game.swf", "flashcontent", gamewidth, gameheight, "10.1", "/flash/expressinstall.swf", flashvars, params); </script>
on page add resize events.
if (window.addeventlistener) { window.addeventlistener("load", resizegame, false); window.addeventlistener("resize", resizegame, false); } else if (window.attachevent) { window.attachevent("onload", resizegame); window.attachevent("onresize", resizegame); } else { window.onload = function() {resizegame();}; window.onresize = function() {resizegame();} }
here resizegame function
function resizegame(isieresize) { var flash = document.getelementbyid('flashcontent'); var screen = screensize(); var width = screen.width; var height = screen.height; var left = 0; var top = 0; if (height * 1.5 > width) { height = width / 1.5 } else { width = height * 1.5; } flash.width = width; flash.height = height; document.getelementbyid('flashcontent').style.width = width + 'px'; document.getelementbyid('flashcontent').style.height = height + 'px'; document.getelementbyid('flashcontent').style.top = '50%'; document.getelementbyid('flashcontent').style.left = '50%'; if (width < screen.width) { left = (screen.width - width) / 2 + left; } if (height < screen.height) { top = (screen.height - height) / 2; } document.getelementbyid('game-box').style.top = top + 'px'; document.getelementbyid('game-box').style.left = left + 'px'; } function screensize() { var w, h; w = (window.innerwidth ? window.innerwidth : (document.documentelement.clientwidth ? document.documentelement.clientwidth : document.body.offsetwidth)); h = (window.innerheight ? window.innerheight : (document.documentelement.clientheight ? document.documentelement.clientheight : document.body.offsetheight)); return {width:w, height:h}; }
and here question: in ie7 function screensize() gives me wrong height on load. under other browsers , ie>7 function screensize() gives me correct height. that's why can't resize content properly. , when explicitly resize window, function screensize() starts give correct height. here screens before explicit resizing , after it.
screensize() gives strange height in ie7.
i ready add information find reason of situation. hope can me find out how define iframe height in ie7. useful.
Comments
Post a Comment