qadenza
qadenza

Reputation: 9293

How to redirect to one level up?

params.php

$minw = 640;

<script>
    var minw = <?php echo $minw;?>;
    var w1 = document.documentElement.clientWidth;
    if (w1 < minw) {location.href = '../minw.php'};
</script>

path to params.php and minw.php is localhost/x1/params.php or minw.php.

params.php is included in stone.php and path to stone.php is localhost/x1/mem/stone.php.

So, I go to stone.php and screen width is less then 640;

I got the browser message - Object not found and in the address bar I see: localhost.minw.php

Then I changed the code ../minw.php into minw.php or ./minw.php in params.php.

Go again to stone.php, got the same browser message and in address bar I see localhost/x1/mem/minw.php.

So, how can I redirect from localhost/x1/mem/stone.php to localhost/x1/minw.php ?

Upvotes: 2

Views: 395

Answers (2)

MCRocks999
MCRocks999

Reputation: 129

Here's a new answer that I think will help you:

$minw = 640;
echo '<script>
URL = location.href;
var URL = URL.replace("mem/stone.php", "minw.php");
var minw = '.$minw.';
var w1 = document.documentElement.clientWidth;
if (w1 < minw) {location.href = URL};
</script>';

Upvotes: 1

MCRocks999
MCRocks999

Reputation: 129

Try this:

URL = location.href;
var URL = URL.replace("mem/stone.php", "minw.php");
var minw = <?php echo $minw;?>;
var w1 = document.documentElement.clientWidth;
if (w1 < minw) {location.href = URL};

EDIT: Also I didn't check for errors in your code so beware of that. I only checked if I made any errors. So all the new code on there is probably error free.

Upvotes: 1

Related Questions