साथ AngularJS का उपयोग कर रहे तुम सिर्फ जावास्क्रिप्ट का उपयोग कर रहे हैं, तो आप देख सकते हैं कि आप इस लिंक से बटन वापस निष्क्रिय कर सकते हैं:
http://jordanhollinger.com/2012/06/08/disable-the-back-button-using-html5/
लेकिन इस ऊपर कोड AngularJS के साथ अच्छी तरह से काम नहीं करेगा क्योंकि AngularJS पृष्ठभूमि में URL_Hash # का उपयोग करता है, इसलिए यहां मैं दिखाऊंगा कि आप कैसे बदल सकते हैं:
आपके मुख्य जावास्क्रिप्ट कोड (AngularJS कोड या नियंत्रक के अंदर नहीं) में, निम्न कोड डालें :
// *** Author: Wael Sidawi
// **** Deactive Back Button ****
var history_api = typeof history.pushState !== 'undefined';
// history.pushState must be called out side of AngularJS Code
if (history_api) history.pushState(null, '', '#StayHere'); // After the # you should write something, do not leave it empty
और अब अंदर अपने AngularJS Controler निम्नलिखित घटना listner डाल:
/**
* Event-Listner for Back-Button
*/
$scope.$on('$locationChangeStart', function(event, next, current){
// Here you can take the control and call your own functions:
alert('Sorry ! Back Button is disabled');
// Prevent the browser default action (Going back):
event.preventDefault();
});
मुझे आशा है कि यह आपकी मदद कर सकता है।
बेस्ट सादर
वाएल
अपने AngularJS भाग के लिए, बस इस लेख http://stackoverflow.com/questions/15813850/detect-history-back-using-angular उपयोग करते हैं, वहाँ के एक समूह रहे हैं समान प्रश्न तो तुरंत पोस्ट न करें ... –
@FerTo http://stackoverflow.com/help/self-answer –