Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Back Button Behavior When No History Available #4732

Closed
triwav opened this issue Jul 22, 2012 · 4 comments
Closed

Back Button Behavior When No History Available #4732

triwav opened this issue Jul 22, 2012 · 4 comments

Comments

@triwav
Copy link

triwav commented Jul 22, 2012

This isn't so much a bug as a feature improvement I'd like to see if possible. If a user goes directly to a page in my mobile app. Say they came to the page from google or something like that. If I use data-rel="back" then it will take them back to the page that referred them to my app not to the correct previous page. For the time being I'm just not using data-rel="back" but it would be nice to have it detect if the previous link is on the same domain or something and if it isn't then use the regular link instead.

@johnbender
Copy link
Contributor

"If I use data-rel="back" then it will take them back to the page that referred them to my app not to the correct previous page"

What is the correct previous page here? Are you saying that the markup looks something like:

<a href="/foo/bar" data-rel="back">Back</a>

The major problem with this is that the link goes to two different places depending on where the user came from and we, as a library, are then dictating to users how the application should handle the behavior of a back button in their apps when there is no internal history.

There may in fact be apps now that expect to be able to go back to the previous page using the back button.

Leaving this open for later consideration.

@triwav
Copy link
Author

triwav commented Jul 23, 2012

The back functionality should have priority in this case. No doubt about that. But let's say this is the first page in a new window or it's not a local page because they found the link through Google so it sends them back to Google. Maybe the best option would be if you could setup a way to have a user callback function of whether the back function should be used or not. That way I can have something like this:

// If referrer isn't set or it doesn't contain mydomain.com then ignore back button functionality
if(document.referrer == "" || document.referrer.indexOf("mydomain.com") == -1){
return false;
}
return true;

@johnbender
Copy link
Contributor

@triwav

Yah it'd have to be some sort of config option and a callback makes the most sense. Definitely something we'll consider.

@jaspermdegroot
Copy link
Contributor

@triwav

I think it would be tricky to use document.referrer in the framework because that is not always reliable (depends on browser). So this could cause the back button functionality being ignored where it shouldn't.
So we might have to look for another solution if we want to support this.

Anyway, I added your request to the wiki page (https://github.com/jquery/jquery-mobile/wiki/Feature-Requests) in the navigation section.

Closing as a feature request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants