Answer the question
In order to leave comments, you need to log in
Is it possible to close a pop-up by clicking on the back button on a smartphone/tablet?
Hello. Actually, the question is in the title)
Is there any handler for the "back" button of mobile devices in js?
Answer the question
In order to leave comments, you need to log in
Theoretically it should help.
1. determine that a smartphone/tablet is currently being used
2. if so: declare some global variable that would be responsible for opening the popup (myPopupOpen) and add this when calling the popup:
history.pushState(null, null, null); // добавляем пустой стейт в историю
window.onpopstate = function(event) {
if (popupOpen) {
closePopUp(); // закрываем попап
}
window.onpopstate = null; // удаляем обработчик события перехода по истории
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question