Reputation: 147
After adding this short js code:
$(document).ready(function() {
//check to see if it's an external link and if so do the splashpage
$('a').click(function() {
var $this = $(this);
//get the redirect url
var redirect_url = $this.attr('href');
var string_url = String(redirect_url);
if (string_url.indexOf("http") !== -1) {
$('#external_link_modal').modal({
overlayClose: true,
overlayCss: {
backgroundColor: "#ebebeb"
}
});
setTimeout(function() {
window.location.replace(string_url);
}, 2500);
return false;
}
});
});
When someone clicks on a link (say on Page A) it pops up a warning then after some time, redirect the user to the new url (say Page B).
However, when someone clicks the browser's 'Back' button on page B, instead of taking user to Page A like it's supposed to, it actually takes him to the page viewed before Page A.
It's really weird. Does anyone have any idea why?
Thanks beforehand!
Upvotes: 0
Views: 739
Reputation: 66465
window.location.replace(string_url)
replaces the current history entry with string_url
. You should set window.location.href
instead:
window.location.href = string_url;
Upvotes: 3
Reputation: 8647
I haven't tested this, but try replacing:
window.location.replace(string_url)
with:
window.location.href=string_url
Let me know if that solves the problem or if it exhibits the same behavior.
Upvotes: 1