-1

With :target => '_blank' in Rails view, a new browser tab within the same browser could be launched as below.

<%= link_to 'Dataset', @dataset_url, target: '_blank' %>

However if we want to open a window in a whole new browser, how do we accomplish that?

user938363
  • 9,990
  • 38
  • 137
  • 303
  • Short answer you can't, you can open a new window of the current browser with `window.open(url);` in js – CWitty Dec 04 '15 at 22:43
  • You go into your browser options and unselect "open new windows in a new tab instead" (FireFox). It's not the webserver's choice to make. I wouldn't be surprised if there is a way to do it, but ... you shouldn't want to do it. Don't override user choices, it just makes people (me) angry when using sites like that. – TessellatingHeckler Dec 04 '15 at 22:44
  • `TessellatingHeckler`, angry with a new window? I want to present information in a whole new browser and this is my question about. – user938363 Dec 04 '15 at 23:20

1 Answers1

1

Yes absolutely possible with javascript pls this link http://progblog10.blogspot.co.uk/2013/01/rails-opening-new-browser-tab-or-window.html

Padhu
  • 1,590
  • 12
  • 15
  • Tried the `onclick:` and it opened a new tab but not a whole new browser. It behaves the same as `target: '_blank'` – user938363 Dec 04 '15 at 23:29
  • You should add some additional parameters as well, window.open(url, windowName, "height=200,width=200") check this same issue http://stackoverflow.com/questions/726761/javascript-open-in-a-new-window-not-tab – Padhu Dec 04 '15 at 23:57
  • This one works: `<%= link_to 'Dataset', @dataset_url, onclick: "var w = window.open(this.href, height=200,width=200); w.focus(); return false;" %>` – user938363 Dec 05 '15 at 00:11