I want to set the window width (getting by JavaScript) in a PHP variable and use it to describe the attribute of the div container, but the following code doesn't work...
<?php
header("Content-type: text/css; charset: UTF-8"); // Parsing CSS zu PHP
echo "<script type='text/javascript'>
if(typeof(window.innerWidth) !== 'number') {
if(document.documentElement.clientWidth !== 0) {
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
}
else {
width = document.body.clientWidth;
height = document.body.clientHeight;
}
}else {
width = window.innerWidth;
height = window.innerHeight;
}
$cwidth = document.write(width);
</script>";
?>
@charset "UTF-8";
#container
{
width: <?php echo $cwidth . 'px'; ?>;
}
Greets