Hi at all!
I want to use a javascript variable in php. The reason is that i want
to know the client's screen resolution.
Keep in mind that i am not a javascript programmer but php.
Here is the code i'm using:
<head>
<script language='JavaScript'>
<!--
var a=(screen.width-750)/2;
function getvariable(val) {
var dummy = eval(val);
document.write(dummy);
}
// -->
</script>
<?php
function get_JS_var($js_var_name) {
$x = "<script> getvariable('" . $js_var_name . "'); </script>";
return $x;
}
?>
</head>
<body>
<?php
$screen_pos = get_JS_var("a");
$b="left:".$screen_pos."";
?>
<div style="position:absolute; <?print $b;?>; top:0; z-index:4">
etc....
</body>
The problem is that if i output the $b outside the div element, it
displays to the browser the right result. But inside the div element
it outputs the
left:<script> getvariable('a'); </script> and so the layer apears in
wrong place.
Any ideas about this or other way to manage to output the div content
in a place according to the client's screen resolution?
Thanks in advance.