Ciao.

Chiedo l'aiuto ddel pubblico per un problema.

Voglio - con JS e SENZA utilizzare i cookie, trovare la risoluzione dello schermo.
Devo per fare usare un form con metodo POST; quindi la scelta è quella indicata sotto.

A parte le poche righe di PHP che servono per vedere se in pratica l form è stato submitato o no, il js serve per scrivere un form che si autoinvia, i cui risultato (nella variabile $_POST) lo vado poi a leggere con php.

Il problema è che sembra la document.write non funzioni, e non faccia un bel niente (leggendo la variabile $_POST essa è vuota). Riuscite a farmi capire perché?

Grazie mille,



codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test</title>
<?php
if(!isset($_POST['submit']))
{

?>
<form name="resolution" action="index.php"method="POST">

<script type="text/javascript">
width = screen.width; 
height = screen.height;
document.write("<input type=hidden name="height" value=\"");
document.write(height);
document.write("\"</>");
document.write("<input type=hidden name="width" value=");
document.write(width);
document.write("</>");

</script>
<input type = submit>
</form>

<script type="text/javascript">
window.document.forms["resolution"].submit();
</script>
<?php
}
else 
{
print_r($_POST);
    

// Code to be displayed if resolutoin is detected
     if(isset($_POST['width']) && isset($_POST['height'])) {
     $_SESSION['width'] =  $_POST['width'];         // Resolution  detected
     $_SESSION['height'] = $_POST['height'];         // Resolution  detected
     }
     else {
               echo'Resolution not detected';
     }
}
</head>
<body>
</body>
</html>