Close pop up on back button

后端 未结 10 1538
长发绾君心
长发绾君心 2020-12-08 08:15

I want to close pop up on click of back button for mobile. I implemented this using onhashchange:

window.onhashchange = function (event) {

};
10条回答
  •  旧时难觅i
    2020-12-08 08:37

    By clicking back, automatically $('.modal').hide() function get activated. So no need to hide modal. We can see grey shaded background after back button.You can use either of these line of code to close modal pop up.

    1. $('.modal' ).modal( 'hide' ).data( 'bs.modal', null ); [work on bootstrap 3]

    Or

    1. $('body').removeClass('modal-open');

      $('.modal-backdrop').remove();

    Inspect the page when modal is active you can see these classes. Do correct me if this method is wrong or other simple way exist.

提交回复
热议问题