How to open bootstrap modal as soon as the page opens, if the modal identifier is present in the URL #

Is there a way in which a user opens the URL http://www.website.com/page/#delete-page , and if this page has a twitter bootstrap with the same delete-page ID, it should open immediately.

So, theoretically, the user opens the URL, the page loads, and after it loads successfully, the modal opens (I ... if it exists, if not, then nothing happens)

+4
source share
2 answers

What you need?

+12
source

Try something like this, it should work.

  $(document).ready(function() { if(window.location.href.indexOf('#myModal') != -1) { $('#myModal').modal('show'); } }); 

or

 $(document).ready(function() { if(window.location.href==='mysite.com/#myModal'){ $('#myModal').modal('show'); } } 
0
source

All Articles