1

i am trying to implement this:

https://stackoverflow.com/a/30225669/533426

but, a simple open window does not work, see here:

http://codepen.io/anon/pen/LkLNaX

javascript:

 window.open('http://www.bippo.com', '_blank');
alert("wtf");

am i missing something?

this should work especially well on android and iphone phones.

Community
  • 1
  • 1
Toskan
  • 13,911
  • 14
  • 95
  • 185
  • General rule in browsers is it requires a user event to be able to open a new window due to abuse/security. Also depends on user security settings ... some might see a prompt...others see nothing if you try to open without user event – charlietfl Jul 04 '16 at 02:10
  • See the correct answer in [this post](http://stackoverflow.com/questions/9514698/bypass-popup-blocker-on-window-open-when-jquery-event-preventdefault-is-set) same idea. – bwegs Jul 04 '16 at 02:13
  • even if manually triggering it, it won't work: see http://codepen.io/anon/pen/LkLNaX – Toskan Jul 04 '16 at 02:13
  • In your script there are several undefined variables (top, left...). It can't work if you don't fix that. – Fernando Jan 10 '18 at 11:02

3 Answers3

0

Maybe you redefined the open function elsewhere or window.open() isn't called directly by a user action. Specially in mobile browsers, you can't call this function from a timer or any asynchronous task.

Alexandre Martin
  • 1,472
  • 5
  • 14
  • 27
-2

try this

<a href="javascript:test()">test</a>

function test(){
    window.open("http://www.bippo.com",'_blank');
    alert("wtf");  
}
Aymen Labidi
  • 107
  • 1
  • 10
-2

Your codepen code work, just check your browser popup block.

window.open("http://www.bippo.com",'_blank');
hendry91
  • 93
  • 2
  • 10
  • the error message is this: `pen.js:2 Uncaught SecurityError: Blocked a frame with origin "http://s.codepen.io" from accessing a frame with origin "http://codepen.io". Protocols, domains, and ports must match.` – Toskan Jul 05 '16 at 18:46