# page \<\< "window.open('http://www.google.com');"   \<\<--- HAS NO EFFECT

**URL:** <https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591>\
**Category:** rubyonrails-talk\
**Created:** [October 23, 2007, 4:22pm UTC](https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591 "2007-10-23T16:22:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alain\_Ravet](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@Alain\_Ravet](https://discuss.rubyonrails.org/u/Alain_Ravet)\
**Post date:** [October 23, 2007, 4:22pm UTC](https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591/1 "2007-10-23T16:22:48Z")

</div>

Hi all,

In an AJAX action, I want to open a new window. problem: the code below does not work : I see the 2 alerts, but 'window.open' does not open a new window.

controller :

---

<div class="post-metadata">

**Author:** ![Jason\_Roelofs](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@Jason\_Roelofs](https://discuss.rubyonrails.org/u/Jason_Roelofs)\
**Post date:** [October 23, 2007, 4:27pm UTC](https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591/2 "2007-10-23T16:27:34Z")

</div>

Go get Firebug: [http://www.getfirebug.com/](http://www.getfirebug.com/)

If you’re still stuck, post what the resulting error is.

Jason

---

<div class="post-metadata">

**Author:** ![Bob\_Showalter](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@Bob\_Showalter](https://discuss.rubyonrails.org/u/Bob_Showalter)\
**Post date:** [October 23, 2007, 4:42pm UTC](https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591/3 "2007-10-23T16:42:12Z")

</div>

Ditto on Firebug.

Probably a popup blocker is preventing the window from opening. I'm not sure how to work around that. Try disabling your popup blocker to verify that is the problem.

---

<div class="post-metadata">

**Author:** ![Chris\_Hall](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@Chris\_Hall](https://discuss.rubyonrails.org/u/Chris_Hall)\
**Post date:** [October 23, 2007, 4:44pm UTC](https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591/4 "2007-10-23T16:44:45Z")

</div>

have you tried:

page.call 'window.open', '[http://www.google.com](http://www.google.com)'

---

<div class="post-metadata">

**Author:** ![Alain\_Ravet](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@Alain\_Ravet](https://discuss.rubyonrails.org/u/Alain_Ravet)\
**Post date:** [October 23, 2007, 7:40pm UTC](https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591/5 "2007-10-23T19:40:39Z")

</div>

> Probably a popup blocker is preventing the window from opening.

That was it, not that it makes sense : the Firefox popup-blocker will

\* allow (open)

&nbsp;&nbsp;&nbsp;\<%= link\_to "open a new window", root\_path, :target =\> 'child2' %\>

\* but not

&nbsp;&nbsp;&nbsp;&nbsp;render(:update){ |page| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;page \<\< "window.open('#{root\_path}');" &nbsp;&nbsp;&nbsp;&nbsp;}

2° : I fear a double "NO", but I'll ask anyway : is there \* another javascript way to \_open\_ a window that would go through the popup blocker, or \* a way to \_detect\_ (even indirectly) that the client's browser has a popup blocker on?

Alain

---

<div class="post-metadata">

**Author:** ![M\_Graff](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@M\_Graff](https://discuss.rubyonrails.org/u/M_Graff)\
**Post date:** [October 23, 2007, 7:48pm UTC](https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591/6 "2007-10-23T19:48:10Z")

</div>

A quick Google resulted in this:

[http://www.visitor-stats.com/articles/detect-popup-blocker.php](http://www.visitor-stats.com/articles/detect-popup-blocker.php)

Looks like it might work to detect the blocker.

Note that their javascript is sort of... lame. The trick of opening a window and seeing if it is set makes sense, but they always close the window's object, which will likely fail. You probably want to move that into the 'if the window opened' code only.

If you are doing this trick, I'd highly recommend only doing it once then storing it on the session or something. Having a small window pop up on every page hit will likely drive your users insane, and having the pop-up window thing appear constantly will likely do the same.

--Michael

---

<div class="post-metadata">

**Author:** ![Alain\_Ravet](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@Alain\_Ravet](https://discuss.rubyonrails.org/u/Alain_Ravet)\
**Post date:** [October 23, 2007, 8:49pm UTC](https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591/7 "2007-10-23T20:49:18Z")

</div>

> [http://www.visitor-stats.com/articles/detect-popup-blocker.php](http://www.visitor-stats.com/articles/detect-popup-blocker.php)

Thanks Michael.

There's a much simpler way actually :

&nbsp;&nbsp;page \<\< "if (confirm('#{msg}') ) {" &nbsp;&nbsp;page \<\< " new\_win=window.open('#{root\_path}');" &nbsp;&nbsp;page \<\< " if (new\_win==null) {alert('Please disable your popup blocker');}" &nbsp;&nbsp;page \<\< "}"

Alain

---

<div class="post-metadata">

**Author:** ![Pablo\_Castellazzi](https://avatars.discourse-cdn.com/v4/letter/p/58f4c7/32.png) [@Pablo\_Castellazzi](https://discuss.rubyonrails.org/u/Pablo_Castellazzi)\
**Post date:** [October 24, 2007, 9:45pm UTC](https://discuss.rubyonrails.org/t/page-window-open-http-www-google-com-has-no-effect/19591/8 "2007-10-24T21:45:10Z")

</div>

Instead of a real browser window, try a javascript one, like this [http://www.stickmanlabs.com/lightwindow](http://www.stickmanlabs.com/lightwindow)
