Center a DIV containing Flash if the browser is resized
I forgot where I found this (please contact me if you’d like credit). It’s a neat JavaScript function to automatically re-center a centered Flash div on resize. (Say that three times fast!)
<head>
<SCRIPT language="JavaScript">
<!--
function InitFlashDiv()
{
var winW = 630, winH = 460;
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") {
winW = window.innerWidth;
winH = window.innerHeight;
}
if (navigator.appName.indexOf("Microsoft")!=-1) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
DIVNAME.style.left=parseInt(winW-800)/2+"px"
}
}
//-->
</SCRIPT>
</head>
<BODY onLoad="InitFlashDiv();" onResize="InitFlashDiv();">
<div id="DIVNAME" style="position:absolute;top:151px;left:25;">
Content
</div>
0 Comments:
Posta un commento
<< Home