0

How do I open the url in a new tab? I know I must use _blank or window.open, but I cannot get it to work.

var url = 'https://google.com',
    delay = 5000; // Milliseconds: 1sec x 1000

   setTimeout(function () {
   window.location = url;
}, delay);
Sneaky
  • 21
  • 1
  • 4
  • Note that a new tab (or window) will have to be opened while handling a user action, such as a link or button click. Browsers' popup blockers will prevent it in most other circumstances, including after a `delay`. – Jonathan Lonowski Jul 18 '17 at 19:36
  • Yeah, I do have a button linked to the function. And even with it linked I still got a pop-up block that I had to enable. – Sneaky Jul 18 '17 at 19:37
  • 1
    Remove the `setTimeout()`. The window should be opened while the event is still being processed, and the timeout pushes it to after that. – Jonathan Lonowski Jul 18 '17 at 19:38

0 Answers0