Récupérer et ajuster taille
Bonjour,
alors voila, j'ai un script qui est sence me centrer ma page web. Mais voila, copmme il y a toujours un chargement et un decalage de ma page, j'ai essayé de passer en paramètre de session une certaines valeur qui evitera ce decalage.
VOila mon script:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| window.onload = function ()
{
var lmt = document.getElementById('centrage');
var container = document.documentElement;
if(lmt && container)
{
var containerHeight;
if (container.innerWidth)
{
containerHeight = container.innerHeight;
}
else
{
containerHeight = container.clientHeight;
}
var lmtHeight;
if (lmt.innerWidth)
{
lmtHeight = lmt.innerHeight;
lmtHeight = 600;
}
else
{
lmtHeight = lmt.offsetHeight;
lmtHeight = 600;
}
var y = Math.ceil((containerHeight - lmtHeight) / 2);
var y = Math.ceil((containerHeight - 700) / 2);
if(y < 0)
{
y = 0;
}
lmt.style.position = "relative";
lmt.style.top = y + "px";
$('a').attr("href", "?myheight="+ y);
} |
et dans ma page php:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <?php session_start(); ?>
<?php include("header.php"); ?>
<script type="text/javascript" language="javascript" src="script/script.js"> </script>
<?php include("lightbox.php") ?>
<link rel="shortcut icon" type="image/x-icon" href="images/sittelles.png" />
<title>Hôtel, restaurant "Les Sitelles ***"</title>
<?php
if(isset($_GET['myheight'])){
$_SESSION['hauteur_page']=$_GET['myheight'];
}
if(isset($_SESSION['hauteur_page'])){ ?>
<style type="text/css">
<!--
#centrage {
top:<?php echo $_SESSION['hauteur_page']; ?>px;
}
-->
</style>
<?php } ?> |
Dans mon url, on obtiens bien: ".php?myheight=132".
Le problème, c'est qu'il semble que cette valeur ne soit pas récupérer...
Si quelqu'un saurait m'aider...
Cordialement,
Ctesias