Skip to content

Instantly share code, notes, and snippets.

@snipe
Forked from jkeck/gist:3515705
Last active August 27, 2015 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snipe/741e6c1df72db7059ddc to your computer and use it in GitHub Desktop.
Save snipe/741e6c1df72db7059ddc to your computer and use it in GitHub Desktop.
Link directly to an open modal window in Bootstrap
/* 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.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment