jquery - bookmark modal window so next time it opens if the page is open -


using bootstrap.

i have lot of links on page. clicking on of links bringing modal window.

the question:

i able bookmark modal window next time use bookmark specific modal window appears.

perhaps use hashtag in url e.g. www.website.com/foo#modal1 , make script displays modal depending on hashtag.

javascript:

$(document).on("ready", function(){      if(window.location.hash == '#modal1')     {         $("#modal1").modal('show');     }     $(".open-modal").click(function(){         $("#modal1").modal('show');         window.location.hash = 'modal1';     });      $(".close-modal").click(function(){         $("#modal1").modal('hide');         window.location.hash = '';     });  }); 

html:

<div id="modal1" class="modal hide fade"> modal <button class="close-modal">close modal</button> </div>  <button class="open-modal">open modal</button> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -