Forum: Ruby on Rails link_to popup

Posted by Avi (Guest)
on 2012-12-08 08:16
(Received via mailing list)
Hello All,

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

<%= link_to "Google", "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
Posted by Alex Mercer (Guest)
on 2012-12-08 15:04
(Received via mailing list)
*link_to "GOOGLE", "http://www.google.com", **:class **=>* *"_blank"*
Posted by Walter Davis (walterdavis)
on 2012-12-08 16:39
(Received via mailing list)
:target => '_blank' will do this.

Walter
Posted by Avi (Guest)
on 2012-12-10 05:47
(Received via mailing list)
On Saturday, December 8, 2012 7:32:39 PM UTC+5:30, Alex Mercer wrote:
>
> *link_to "GOOGLE", "http://www.google.com", **:class **=>* *"_blank"*
>
>
>
I tried with *:class **=>* *"_blank". * It seems to be opening in the 
same
page.
Posted by Avi (Guest)
on 2012-12-10 05:48
(Received via mailing list)
:target => '_blank' . It is opening in a different tab in the same 
browser.
Posted by Walter Davis (walterdavis)
on 2012-12-10 05:55
(Received via mailing list)
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
Posted by avinash behera (Guest)
on 2012-12-10 05:57
(Received via mailing list)
Should we use javascript ot jquery to achieve this?
Posted by Jim ruther Nill (jimboker)
on 2012-12-10 06:10
(Received via mailing list)
On Mon, Dec 10, 2012 at 12:55 PM, avinash behera
<aavinash.behera@gmail.com>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

http://apidock.com/rails/v2.3.8/ActionView/Helpers...


>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



--
Posted by Walter Davis (walterdavis)
on 2012-12-10 06:23
(Received via mailing list)
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.

http://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
Posted by Jordon Bedwell (Guest)
on 2012-12-10 06:24
(Received via mailing list)
On Sun, Dec 9, 2012 at 10:55 PM, avinash behera
<aavinash.behera@gmail.com> 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;")
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.