Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open bootstrap modal as soon as page opens if modal id is present in url #

Is there any way using which when a user opens a url http://www.website.com/page/#delete-page and if that page has a twitter bootstrap modal with same id delete-page it should open instantly.

So in theory the user opens the url, The page loads and after its successfully loaded the modal opens (i..e if it exists if not then nothing happens)

like image 430
Dhruv Kumar Jha Avatar asked Dec 11 '22 17:12

Dhruv Kumar Jha


1 Answers

What do you need?

  1. Get the hash from the URL: How can you check for a #hash in a URL using JavaScript?
  2. Once you have the hash, simple get the element with the id selector of the hash and then:

    $(hash).modal('show')
    
like image 88
Pigueiras Avatar answered Dec 18 '22 00:12

Pigueiras