page << "'');" <<--- HAS NO EFFECT

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
'' does not open a new window.

controller :

Go get Firebug:

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


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.

have you tried: '', ''

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)

   <%= link_to "open a new window", root_path, :target => 'child2' %>

* but not

    render(:update){ |page|
      page << "'#{root_path}');"

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?


A quick Google resulted in this:

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


Thanks Michael.

There's a much simpler way actually :

  page << "if (confirm('#{msg}') ) {"
  page << "'#{root_path}');"
  page << " if (new_win==null) {alert('Please disable your popup
  page << "}"


Instead of a real browser window, try a javascript one, like this