Open Modal From alias

by freedawirl

HTML

<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css">
<!-- Large modal -->
<a class="btn btn-primary" data-toggle="modal" href="#open">Large modal</a>

<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" id="open">
    <div class="modal-content">
     Content of Modal
    </div>
  </div>
</div>

JavaScript

/* If you've ever had the need to link directly to an open modal window with Bootstrap, here's a quick and easy way to do it:
Make sure your modal has an id and is classed with modal and permalink:
<div class="modal permalink" id="myModal" ... >
Then stick this bit of Javascript at at the end of your document:
 */

$(document).ready(function() {
  $(".modal.permalink").each(function(){
    if(window.location.href.indexOf($(this).attr("id")) != -1){
      $(this).modal('show');
    }
  });
});

/*
Then you can send people to http://www.website.com/page.html#myModal and it'll load the page with the modal open.
*/