# Link\_to popup

**URL:** <https://www.ruby-forum.com/t/link-to-popup/225040>\
**Category:** Rails\
**Created:** [December 8, 2012, 8:16am UTC](https://www.ruby-forum.com/t/link-to-popup/225040 "2012-12-08T08:16:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [December 8, 2012, 8:16am UTC](https://www.ruby-forum.com/t/link-to-popup/225040/1 "2012-12-08T08:16:13Z")

</div>

Hello All,

I have a link. Which I want to open as a new window :-

\<%= link\_to “Google”, “[https://www.google.com](https://www.google.com)”, :popup =\>  
[‘new\_window\_name’,‘toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes’]  
%\>

But it is opening in the same page…  
Any suggestions how to do it ??  
Even hover will be fine…

Thanks,  
Avi

---

<div class="post-metadata">

**Author:** ![Avi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Avi](https://www.ruby-forum.com/u/Avi)\
**Post date:** [December 8, 2012, 3:04pm UTC](https://www.ruby-forum.com/t/link-to-popup/225040/2 "2012-12-08T15:04:30Z")

</div>

\*link\_to “GOOGLE”, “[http://www.google.com](http://www.google.com)”, \*\*:class \*_=\>_ _“\_blank”_

---

<div class="post-metadata">

**Author:** ![Avi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Avi](https://www.ruby-forum.com/u/Avi)\
**Post date:** [December 8, 2012, 4:39pm UTC](https://www.ruby-forum.com/t/link-to-popup/225040/3 "2012-12-08T16:39:08Z")

</div>

:target =\> ‘\_blank’ will do this.

Walter

---

<div class="post-metadata">

**Author:** ![Avi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Avi](https://www.ruby-forum.com/u/Avi)\
**Post date:** [December 10, 2012, 5:48am UTC](https://www.ruby-forum.com/t/link-to-popup/225040/4 "2012-12-10T05:48:09Z")

</div>

:target =\> ‘\_blank’ . It is opening in a different tab in the same  
browser.

---

<div class="post-metadata">

**Author:** ![Avi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Avi](https://www.ruby-forum.com/u/Avi)\
**Post date:** [December 10, 2012, 5:47am UTC](https://www.ruby-forum.com/t/link-to-popup/225040/5 "2012-12-10T05:47:33Z")

</div>

On Saturday, December 8, 2012 7:32:39 PM UTC+5:30, Alex M. wrote:

> \*link\_to “GOOGLE”, “[http://www.google.com](http://www.google.com)”, \*\*:class \*_=\>_ _“\_blank”_

I tried with \*:class \*_=\>_ \*“\_blank”. \* It seems to be opening in the  
same  
page.

---

<div class="post-metadata">

**Author:** ![Avi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Avi](https://www.ruby-forum.com/u/Avi)\
**Post date:** [December 10, 2012, 5:57am UTC](https://www.ruby-forum.com/t/link-to-popup/225040/6 "2012-12-10T05:57:30Z")

</div>

Should we use javascript ot jquery to achieve this?

---

<div class="post-metadata">

**Author:** ![Avi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Avi](https://www.ruby-forum.com/u/Avi)\
**Post date:** [December 10, 2012, 5:55am UTC](https://www.ruby-forum.com/t/link-to-popup/225040/7 "2012-12-10T05:55:09Z")

</div>

On Dec 9, 2012, at 11:47 PM, Avi wrote:

> :target =\> ‘\_blank’ . It is opening in a different tab in the same browser.

That’s an implementation detail of your browser. The target=“\_blank” bit  
is baked into every browser back to Netscape 2. How that browser chooses  
to implement the window (or tab) is its concern, not something you can  
change.

Walter

---

<div class="post-metadata">

**Author:** ![Avi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Avi](https://www.ruby-forum.com/u/Avi)\
**Post date:** [December 10, 2012, 6:10am UTC](https://www.ruby-forum.com/t/link-to-popup/225040/8 "2012-12-10T06:10:21Z")

</div>

On Mon, Dec 10, 2012 at 12:55 PM, avinash behera  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Should we use javascript ot jquery to achieve this?

I remember in rails 2 that link\_to has a popup option which opens a new  
window. Looking at  
the api right now, the option was removed. so I guess you may need to  
implement your  
own js solution

> **[ActionView::Helpers::UrlHelper#link\_to - APIdock](https://apidock.com/rails/v2.3.8/ActionView/Helpers/UrlHelper/link_to)**
>
> ActionView::Helpers::UrlHelper#link\_to - Ruby on Rails API documentation. View source code and usage examples.

> –  
> You received this message because you are subscribed to the Google G.  
> “Ruby on Rails: Talk” group.  
> To post to this group, send email to [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> To unsubscribe from this group, send email to  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

–

---

<div class="post-metadata">

**Author:** ![Avi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Avi](https://www.ruby-forum.com/u/Avi)\
**Post date:** [December 10, 2012, 6:24am UTC](https://www.ruby-forum.com/t/link-to-popup/225040/9 "2012-12-10T06:24:22Z")

</div>

On Sun, Dec 9, 2012 at 10:55 PM, avinash behera  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Should we use javascript ot jquery to achieve this?

link\_to(:link, :title =\> “Link Title”, :onclick =\>  
“javascript:(function(ele) { window.open(ele.href, ele.title,  
‘toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes’)  
})(this); return false;”)

---

<div class="post-metadata">

**Author:** ![Avi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Avi](https://www.ruby-forum.com/u/Avi)\
**Post date:** [December 10, 2012, 6:23am UTC](https://www.ruby-forum.com/t/link-to-popup/225040/10 "2012-12-10T06:23:12Z")

</div>

On Dec 9, 2012, at 11:55 PM, avinash behera wrote:

> Should we use javascript ot jquery to achieve this?

I just tried this in Safari, and both window.open and target=“\_blank”  
both open in a new tab. There doesn’t seem to be a way to override the  
browser preference here (and I consider that to be a good thing, BTW).

What does seem to work to force a different window altogether is to set  
the window preferences in JavaScript to a defined size. Compare the  
second and the third links on this page. The second (like the first)  
opens a new tab. The third opens a little daughter window, separate from  
the main browser. I haven’t fiddled with it that much to figure out what  
the least-common-denominator thing you can do to force the window, but  
you should be able to find a lot of references to this – it’s  
definitely old-school.

> **[New Window, Three Ways](https://scripty.walterdavisstudio.com/window.html)**

You might also want to think about using a “lightwindow” or similar  
instead of a new window. New windows have lots of other UX issues.

Walter
