admin管理员组文章数量:1201188
I have a payment form in which user can enter all his card details,and when he clicks,he is taken to the banks 3D secure page. But,the problem is, the user can simply click on the back button of the browser and can go back to payment page, if he initiates a "pay now" again,there is a chance of multiple transaction and duplication of ref ids.
So my question is: is there some way I can redirect the user to a custom page when he clicks on back button which says "Session expired, so transaction has been cancelled." so that we avoid duplication of ref ids?
I have a payment form in which user can enter all his card details,and when he clicks,he is taken to the banks 3D secure page. But,the problem is, the user can simply click on the back button of the browser and can go back to payment page, if he initiates a "pay now" again,there is a chance of multiple transaction and duplication of ref ids.
So my question is: is there some way I can redirect the user to a custom page when he clicks on back button which says "Session expired, so transaction has been cancelled." so that we avoid duplication of ref ids?
Share Improve this question edited Dec 25, 2013 at 9:20 user3126593 255 bronze badges asked Dec 25, 2013 at 9:08 user3128920user3128920 4192 gold badges6 silver badges13 bronze badges4 Answers
Reset to default 18Use the below jquery for redirect your own url when clicking browser back button andipedia.com
jQuery(document).ready(function($) {
if (window.history && window.history.pushState) {
$(window).on('popstate', function() {
var hashLocation = location.hash;
var hashSplit = hashLocation.split("#!/");
var hashName = hashSplit[1];
if (hashName !== '') {
var hash = window.location.hash;
if (hash === '') {
alert('Back button was pressed.');
window.location='www.example.com';
return false;
}
}
});
window.history.pushState('forward', null, './#forward');
}
});
If user clicked back button this will redirect you to your specified page (100% Working)
window.history.pushState({page: 1}, "", "");
window.onpopstate = function(event) {
if(event){
window.location.href = 'https://www.google.com/';
// Code to handle back button or prevent from navigation
}
}
You have to use history api, and for better compatibility use history.js plugin.
Handling pressing back button :
$(window).bind('onpopstate', function(e){
//your dark doings here
});
You can use Brooke's modified script. That's a long script (should be used as external file). You can download it here!
Then use the script like this:
bajb_backdetect.OnBack = function(){
document.location.href = 'http://google.com';
}
本文标签: phpRedirect to another url when back button is clicked using javascriptStack Overflow
版权声明:本文标题:php - Redirect to another url when back button is clicked using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738552488a2097641.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论