1

In my website, I need to open the page automatically after 5 seconds, I am using the following code, but my browser is showing POP-UP BLOCKED. Please let me know the solution for my query. Thanks in advance.

$(document).ready(function()
        {
            setTimeout(function(){ 
            window.open("http://www.google.com")}, 5000);
        });
Ramya
  • 21
  • 2
  • 8

3 Answers3

3

Use this instead:

$(document).ready(function () {
  setTimeout(function () {
    window.location.href = "http://www.google.com"
  }, 5000);
});
Amit Singh
  • 2,267
  • 4
  • 25
  • 50
-1

unblock pop up for your browser

yk1007
  • 151
  • 2
  • 16
-1
function open_win() {
    window.open("x.com");
    setTimeout("window.open('y.com')",60000);
    setTimeout("window.open('z.com')",120000);
}

This should open x.com then after one minute y.com and after two it should open z.com. If still there is a pop-up error, check this question's answer: Bypass popup blocker on window.open when JQuery event.preventDefault() is set.

Community
  • 1
  • 1
Ataboy Josef
  • 2,087
  • 3
  • 22
  • 27