Mohammed Kumel
Mohammed Kumel

Reputation: 151

Load Modal on page load & redirect after 5 seconds

I got a modal pop up but has no trigger on it. So its not displaying on page which is perfect. But.

How can i display the modal on page load & also force them to redirect to a page.

Upvotes: 0

Views: 4532

Answers (2)

Stuart
Stuart

Reputation: 6780

Using bootstrap, you open a modal like so:

$('#idOfYourModal').modal('show'); 

If you want to redirect after a certain time, then you should look at setTimeout, something like:

setTimeout(function{ window.location="your/redirect/url.ext";}, 5000);

Upvotes: 3

Muhammad Ali
Muhammad Ali

Reputation: 2014

Oening Modal on page load and redirect after five seconds

$(document).ready(function(){
// Open modal on page load
$("#modal").modal('show');
//redirect after 5seconds
  setInterval(function(){
   window.location = "http://www.yoururl.com";
   },5000)

})

Upvotes: 1

Related Questions