zjk
zjk

Reputation: 2153

Why is window.open blocked while changing window.location.href is fine?

When the running javascript code is triggered by non-user events (timer, ajax ready, etc.), window.open is blocked (in chrome there will be a popup blocker in the url bar).

But changing window.location.href works fine.

I'm wondering why this decision is made. Are there any spec about this? (I only tested on chrome)

Upvotes: 0

Views: 849

Answers (1)

Jamiec
Jamiec

Reputation: 136104

One is trying to open a popup, which people find distracting so browser developers block it.

The other is simply navigating the current page - which would make no sense to block as without that functionality standard links would not work.

Upvotes: 3

Related Questions