This is the JS to detect the screen resolution on my page naming index.html and sending it to php, so that the values can be retrived using $
You can use a javascript lib like jQuery. Instead of:
window.location.href = "http://localhost/main.php?width=" + width + "&height=" + height;
You can call:
$.get("http://localhost/main.php?width=" + width + "&height=" + height, function(data, textStatus, jqXHR) {
// replace the html body with the output of main.php
$('body').html(data); // you might want to customize that
});
Documentation of $.get() jQuery function.