toomanyairmiles
toomanyairmiles

Reputation: 6485

Force a page to reload using a query string

Is there a simple way to force a page to reload using a query string?

I've constructed a low bandwidth version of a website activating via a url foo.com/?il_light_mode=on and foo.com/?il_light_mode=off it works successfully but I'm having some difficulty in getting the browser to reload the page when the user clicks an activation link.


Update A hacky but workable solution is setting the history to 0 foo.com/?il_light_mode=on&javascript:history.go(0) and foo.com/?il_light_mode=off&javascript:history.go(0) but it has the obvious disadvantage of rendering the back button history useless.

Upvotes: 0

Views: 629

Answers (3)

Rikudou_Sennin
Rikudou_Sennin

Reputation: 1375

In php, on the very top use something like this:

<?php
  if(isset($_GET['il_light_mode'])) {
    // DO YOUR ACTIONS
    header("Location: http://foo.com");
    exit;
  }
?>

Upvotes: 1

TazGPL
TazGPL

Reputation: 3748

If I understend correctly, then you're looking for header:

// based on the il_light_mode query parameter check, if light mode should be enabled
$turn_light_mode_on = (isset($_GET['il_light_mode']) and $_GET['il_light_mode'] == 'on') ? true : false;
// redirect to the light version if so
if ($turn_light_mode_on) {
    header('Location: index_light.php');
    die();
}

Upvotes: 1

Collins
Collins

Reputation: 231

You will need to check the current query string and if it matches your need, finally use window.location.href = url;

PS: A non-javascript solution is not possible in my opinion

Upvotes: 0

Related Questions