I would like, when i'm loading a webpage, to add in GET the width and height of the screen, so that my page can use these var to redirect to a specific page.
I've looked for the function and it seems that I should use window.screen.width
and window.screen.height
Also, I figured out I should use $.get()
to send the variables.
So I came out with this script, but i assume i'm mixing JS and AJAX which I don't if it's ok or not. And most of all, I don't know how to run the function when my page is loading.
$(document).ready(function() {
ratio();
function ratio() {
var Vorientation;
if(window.screen.width>window.screen.height)
{
Vorientation = 1;
}
else
{
Vorientation = 2;
}
$.get( "index.php?orientation="+Vorientation );
alert("ok");
}
});
Here is the html :
<body>
<?php
if(isset($_GET['orientation']))
{
echo"ok";
}
?>
</body>