...

View Full Version : Code Check (center a page thats using (DIV"S)



Defiant
07-10-2003, 11:03 PM
This Seems to work ok but is there a simple -er way of centering content of page that uses div's for precise placement?

<BODY SCROLL="auto" onResize="DoReposition();" onLoad="DoReposition();" BGCOLOR="#FFFFFF" LINK="#808080" VLINK="#808080" TOPMARGIN=0 LEFTMARGIN=0>

<SCRIPT LANGUAGE="JavaScript">
<!--
var agt=navigator.userAgent.toLowerCase();
var is_major=parseInt(navigator.appVersion);
var is_minor=parseFloat(navigator.appVersion);
var is_nav=((agt.indexOf('mozilla')!=-1)&&(agt.indexOf('spoofer')==-1)&&(agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)&&(agt.indexOf('webtv')==-1));
var is_ie=(agt.indexOf('msie')!=-1);
if(is_ie){var agt_ie=agt.substring(agt.indexOf('msie')+5); is_major=parseInt(agt_ie); is_minor=parseFloat(agt_ie);}
var is_dom2=(document.getElementById);
// Browser detect
if( is_minor < 5.0 )
alert( "Your browser is very outdated. Please upgrade your browser to version 5 or later." );

//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
function HOffset()
{
var window_width = window.innerWidth ? window.innerWidth : (document.body.clientWidth ? document.body.clientWidth : 0);
return Math.max( 0, Math.floor( (window_width - 760) / 2 ) - 0 ).toString();
}

function VOffset()
{
var window_height = window.innerHeight ? window.innerHeight : (document.body.clientHeight ? document.body.clientHeight : 0);
return Math.max( 0, Math.floor( (window_height - 600) / 2 ) - 0 );
}

document.write( "<DIV ID='IDAlignPage' style='position:absolute; top:" + VOffset() + "px; left:" + HOffset() + "px;'>&nbsp;" );
function DoReposition()
{var o='IDAlignPage';
if(is_dom2&&document.getElementById(o))
{var e=document.getElementById(o);e.style.left=HOffset()+'px';e.style.top=VOffset()+'px';}
else if(is_ie&&is_major>=4&&eval('document.all.'+o)){
var e=eval('document.all.'+o);e.style.left=HOffset()+'px';e.style.top=VOffset()+'px';}
else if(is_nav&&is_major>=4&&eval('document.'+o))
{var c=eval('document.'+o);c.left=HOffset();c.top=VOffset();}}
window.onresize=DoReposition;
window.onload=DoReposition;
//-->
</SCRIPT>

<DIV ID="idstart" editblock="top1"style="position:absolute; top:0px; left:0px; width:760px; height:600px;">start</DIV editblock="top1">

<DIV ID="idElement8" style="position:absolute; top:0px; left:0px; width:758px; height:6px;"><IMG SRC="bar1.gif" NAME="idElement8Img" ID="idElement8Img" WIDTH=758 HEIGHT=6 BORDER=0></DIV>

<DIV ID="idElement9" style="position:absolute; top:6px; left:487px; width:271px; height:43px;"><IMG SRC="col1.gif" NAME="idElement9Img" ID="idElement9Img" WIDTH=271 HEIGHT=43 BORDER=0></DIV>

<DIV ID="idicon" style="position:absolute; top:6px; left:0px; width:57px; height:43px;"><IMG SRC="icon.gif" NAME="idiconImg" ID="idiconImg" WIDTH=57 HEIGHT=43 BORDER=0></DIV>

Thank's for your time, -Maryjane.

beetle
07-11-2003, 01:45 AM
yes

<div style="margin: 0 auto">
<!-- content -->
</div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum