I have a bit of JS code (echoed by PHP) that will be put on the top of my web pages. The code should evaluate the window size, and based on that, go to the mobile version or go to the pc version.
But when i loead my page (pc version), the page keeps refreshing. How can i make the refreshing stop?
Here's the code:
$page = $_SERVER["PHP_SELF"];
echo "<script>";
echo "function screenSizeRedirect()
{
var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
if (width <= 960)
{
window.location = 'http://m.bss21universe.ga$page';
}
if (width > 960)
{
window.location = 'http://www.bss21universe.ga$page';
}
}";
echo "screenSizeRedirect();";
echo "</script>";