A
A
Angelxalfa2015-11-24 18:19:46
JavaScript
Angelxalfa, 2015-11-24 18:19:46

How to set url to open bootstrap modal window?

Good day!
Can you please tell me if it is possible to make a link when clicking on which a page was opened with a bootstrap modal window immediately visible on it?
That is, for example, there is a modal window on page 2 with id=MyModal
On page 1 we place a link , when you click on it, page 2 opens with an already active modal window. Thanks in advance! I solved it using JS: I send a parameter in the GET link and track its value (if it is true, I display a modal window)<a href="www.стр2#MyModal">

<script>
function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}

            $(function(){
  var modal_show = getUrlVars()["modal_show"];
    if (modal_show == 'true') {
        $('#myModal').modal('show')
    }
});
</script>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question