Open new Window

  how to open new window using any rails function.

  now am using redirect_to "http://chennairails.blogspot.com"   but it opens in same window.

Opening new window is only possible on client side (either with target="_blank" or with some javascript magick).

I suggest you to go and study HTML first. After that you'll be able to easily figure out how to do it.

hi,

I know how to open new window in html & in java script. but i want to open new window by using rails functions.

ok bye

http://www.rubyonrails.org/api/classes/ActionView/Helpers/UrlHelper.html#M000378

link_to “Busy loop”, { :action => “busy” }, :popup => [‘new_window’, ‘height=300,width=600’]

If you need to do it from your controller, you’ll need to use RJS to do it:

page.call “window.open('”+myurl+“');”

Best regards

Peter De Berdt

If you want link to open in another window, you supply A tag's "target" attribute with "_blank" value.

In Rails to render a link you use link_to helper. So, you just need to pass that "target='_blank'" to link_to function. link_to accepts html options as third param, so:

   link_to 'Cool site', "http://mycoolsite.example.com", :target => '_blank'

The :popup parameter just does that. Also, you musn’t forget XHTML 1.1 has deprecated the _target parameter in favor of JavaScript.

Best regards

Peter De Berdt

Peter De Berdt <peter.de.berdt@...> writes:

The :popup parameter just does that. Also, you musn't forget XHTML 1.1 has deprecated the _target parameter in favor of JavaScript.

While it's good news that people are pushing standards compliance, this isn't anything to do with XHTML 1.1. The <a> 'target' attributes isn't even present in the HTML 4.01 Strict version :slight_smile:

Gareth, Saving the world one small inaccuracy at a time :wink:

One more reason not to use it :wink:

Best regards

Peter De Berdt