Как закрыть pop-up на мобильном кнопкой "назад" в Tilda
It is always the simple that produces the marvelous
Everything that you dreamed of can be brought to life exactly at the moment when you decide to win.

Как закрыть pop-up на мобильном кнопкой "назад" в Tilda

1
Добавили код в блок Другое - Т123
Библиотека для примера
<script>
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)) {

let popupOpen = false;
let openLink = "#popup";

if(document.location.hash==openLink) document.location.hash='';

let bodyMode = document.querySelector('.t-body');
let observer = new MutationObserver(function (mutations) {
    mutations.forEach(function (mutation) {
        setTimeout(function(){
            if (bodyMode.classList.contains('t-body_popupshowed')) {
                
                let path = window.location.pathname;
                

                if(  (window.location.hash=="" &&  !path.includes('/tproduct/') ) || window.location.hash.includes('/tproduct/') ) {
                    window.location.hash = openLink;
                    popupOpen=true;
                };
                
            }else{
            //    if(window.location.hash == openLink ) history.pushState("", document.title, window.location.pathname);
            };
            
        }, 100);
    });
});
observer.observe( bodyMode, {  attributes: true, attributeFilter: ['class'] });
    
window.addEventListener("hashchange", function(){
   
    let hash = window.location.hash;
    
    if ( hash!=openLink && popupOpen &&  bodyMode.classList.contains('t-body_popupshowed') ){
        let popUpOpn = document.querySelector(".t-popup_show .t-popup__close");
        if(popUpOpn)   popUpOpn.click();

    };
});  

};
</script>
Made on
Tilda