$('.modal').on('shown.bs.modal', function (e) {
window.location.href = '#' + $(this).attr('data-m');
});
$('.modal').on('hidden.bs.modal', function (e) {
history.pushState('', document.title, window.location.pathname);
});
$(window).bind('hashchange', function() {
if(window.location.hash == ''){
$('.modal').modal('hide');
}
});