Simple question. Is it possible to generate a link like
with the link_to function ?
Thanks
On 3.1.2006, at 14.13, oo00oo wrote:
Simple question. Is it possible to generate a link like
with the link_to function ?
Yes:
“Itâ??s also possible to pass a string instead of an options hash to
get a link tag that just points without consideration. If nil is
passed as a name, the link itself will become the name.” [1]
So, <%= link_to “google”, “http://www.google.com” %> should do the job.
//jarkko
[1] Peak Obsession
UrlHelper.html#M000332
Hi, ooOOoo,
as many rails functions the link_to function takes parameters that are
not mandatory for the function as an optional hash. You might write
anything into
this hash. So the answer to your question of a list of possible
:properties would be ‘endless’. See for example:
<%= link_to “google”, “http://www.google.com” , { :foo => “bar” } %>
producing
google
You might have a look at HTML a tag for key
=> value - pairs that make ‘sense’.
Regards
Jan
:target is a HTML (although non XHTML compliant) tag. All other HTML
attributes are valid tags such as :onmouseover, :onclick, :class, :id,
etc
can be used. They are not documented as you should reference W3 for what
HTML tags are truly valid.
-Nb
Nathaniel S. H. Brown http://nshb.net
perhaps :popup => true without sizes options is more simple than js ?
So you know, target=“_blank” is not valid XHTML. I recommend reading
about
using the rel=“external” tag if you so desire to popup a new window.
Here is some sample JavaScript I have in my default JS library code I
use in
such a case to ensure XHTML compliancy:
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName(“a”);
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute(“href”) && anchor.getAttribute(“rel”) ==
“external”) {
anchor.target = “_blank”;
}
}
}
window.onload = externalLinks;
You can find fill documentation for the url_for method at:
http://www.railsmanual.org/class/ActionController%3A%3ABase#meth_url_for
In addition, there are 3 special options for the html_options parameter
with
link_to, outlined here:
http://www.railsmanual.org/module/ActionView%3A%3AHelpers%3A%3AUrlHelper#met
h_link_to
Regards,
Nathaniel
Nathaniel S. H. Brown http://nshb.net
Popus tend to lack all the toolbars due to the nature of what a popup
is.
Unless you stack it with options to match the feature set across all
browsers natively you will find that the JavaScript below may be a more
viable option. Search engines do not appreciate popup links and have a
hard
time following them for indexing, so you might be better off using such
a
tactic as mentioned via the JavaScript rel=“external” option.
-Nb
Nathaniel S. H. Brown http://nshb.net
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs