Question

Consider the following situation:

I start on some page with a URL of page1.com. On that page, there is some button or link that takes me to another page that has a URL with a querystring, like page2.com?value=1&value=2. What I would like to do is find a way to take the querystring ?value=1&value=2 from the second page and append it to the URL for the first page, when a user clicks their browser's back button.

The goal would be: page1.com?value=1&value=2

I am looking for jQuery solutions, only.

Was it helpful?

Solution

You can use JQuery Mobiles navigation event as shown below.

$(window).on("navigate", function (event, data) {
  var direction = data.state.direction;
  if (direction == 'back') {
    window.location.href = 'your link with parameters';
  }
});

Here's a demo.

Demo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top