Thanks to those who responded on this. What I've done is to make a file which uses the javascript to determine the space available in the browser window, viz:

<script type="text/javascript">
  var height = 0;
                                                                
                if( typeof( window.innerWidth ) == 'number' )
                        {
                //Non-IE
                height = window.innerHeight;
                        }
else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
                        {
                        //IE 6+ in 'standards compliant mode'
                height = document.documentElement.clientHeight;
                        }
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
                        {
                //IE 4 compatible
                height = document.body.clientHeight;
                        }
                        if (height>0)
                        {
                window.location.href = "index.php?height="+ height;
                        } else
                exit();
</script>

Of course, since the php is server-side, I then have to send the height variable to the php via another page load (window.location.href).

This page then takes the height, knocks off the div height and divides by 2 to get the correct margin-top, which it then writes to the inline CSS in two sections:

<?php
IF ($_GET['height']<>100)
                {
                $space=$_GET['height'];
                $margin=($space-200)/2;
                } ELSE
                {
                $margin=100;
                }

?>

<?php        
        echo"<div id=\"viewport\"  style=\"margin : ".$margin."px auto;\">\n";
        echo"   <h1>The top margin is set to ".$margin."!</h1>";
        echo"</div>\n ";
?>

I have also trapped it, so that anyone without javascript will get a top-margin of 100px;

You can see all this at:  http://www.rhh.myzen.co.uk/gam/sandbox/

It's a bit clumsy, and I don't like reloading a page, so I'm grateful for any really good /suggestions / improvements!

Thanks.


http://www.rhh.myzen.co.uk/gam/sandbox/i

--
Bob

www.gwelanmor-internet.co.uk



*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************

Reply via email to