试图通过PHP发送window.width(POST上的空白页)

I am trying to figure out a way to save and then echo or print_r the window.innerwidth and window.innerheight..

I did it like below and I keep getting a blank page

first page

<html>

<body>


<form action='trythis2.php' method='POST'>
<input type='hidden' id='dimensions' name='dimensions'>

<input type='submit' value='submit'>
</form>

<script type="text/javascript">

$(window).resize(function() {
    $("#dimensions").html($(window).width());
}).resize();

</script>

</body>

</html>

Second page

<?php


$thisis = $_POST['dimensions'];

print_r($thisis);


?>

and on the POSTED page its just blank no text or anything. I wanted it to show my browsers width.

Use val() to set or retrieve the value of input field. html() is used to set inner html of html elements. Hope this will help.

Svae this code as .php extension

Code:

    <?php

    if(isset($_POST['dimensions'])){

    $thisis = $_POST['dimensions'];

    echo $thisis;

    exit();

    }

    ?>

    <html>
    <head>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    </head>

    <body>

    <form action='' method='POST'>
    <input type='hidden' id='dimensions' name='dimensions'>

    <input type='submit' value='submit'>
    </form>

    <script type="text/javascript">

    $("#dimensions").val($(window).width());

    $(window).resize(function() {
        $("#dimensions").val($(window).width());
    });

    </script>

    </body>
    </html>