Hey Guys I just tried to use new Element("a",{ href:"http://www.google.co.nz", target:"_blank" }); and can''t get the target to take on the generated link, as it it always opens in the current window. Can someone point out what i''ve done wrong, or possibly try the above and tell me if it works for them? Gareth --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You should assign a click event to the link, as target is deprecated HTML. new Element(''a'', { href: ''http://www.google.co.nz'' }).observe(''click'', function(e) { e.stop(); window.open($(this).href, ''PREFIX_WindowName''); }); On Nov 5, 6:35 am, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey Guys > > I just tried to use > > new Element("a",{ href:"http://www.google.co.nz", target:"_blank" }); > > and can''t get the target to take on the generated link, as it it always > opens in the current window. > > Can someone point out what i''ve done wrong, or possibly try the above and > tell me if it works for them? > > Gareth--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Okay, that''s one option, but depsite the attribute being deprecated, shouldn''t it still work? Gareth On 11/5/07, redheat <ecouchman-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > You should assign a click event to the link, as target is deprecated > HTML. > > new Element(''a'', { href: ''http://www.google.co.nz'' }).observe(''click'', > function(e) > { > e.stop(); > window.open($(this).href, ''PREFIX_WindowName''); > }); > > On Nov 5, 6:35 am, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hey Guys > > > > I just tried to use > > > > new Element("a",{ href:"http://www.google.co.nz", target:"_blank" }); > > > > and can''t get the target to take on the generated link, as it it always > > opens in the current window. > > > > Can someone point out what i''ve done wrong, or possibly try the above > and > > tell me if it works for them? > > > > Gareth > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 11/5/07, Gareth Evans <agrath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Okay, that''s one option, but depsite the attribute being deprecated, > shouldn''t it still work?Yeah, it should. I just whipped up a test and target="_blank" worked as advertised. (Browsers tested included Firefox, Opera, Safari, and IE 6.) What browser are you using? Also, I realize your example is devoid of context, but I noticed the link doesn''t have any associated text (e.g., new Element(''a'', { href: ''#'', target: ''_blank'' }).insert(''click me!'')). If that''s also the case in the actual code, that could be your problem. Although, as long as you''re using JS to add "open in new window" functionality anyway, it''s more standards-friendly to add an event handler as previously described. :Dan Dorman --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Okay. Thanks for checking for me Dan, i''m sorry to have wasted your time. I found that I had missed the target attribute on one of the if branches. Context wise, i''m using a regular expression to wrap matching (link) text in anchor tags. It also matches email addresses with a second regular expression and will insert the http:// on the start if it thinks it''s missing. So there''s 3 places I should have put the target. That said, you''re right about the standards-friendlyness. I will switch to using a click handler. Gareth On 11/6/07, Dan Dorman <dan.dorman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 11/5/07, Gareth Evans <agrath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Okay, that''s one option, but depsite the attribute being deprecated, > > shouldn''t it still work? > > Yeah, it should. I just whipped up a test and target="_blank" worked > as advertised. (Browsers tested included Firefox, Opera, Safari, and > IE 6.) What browser are you using? > > Also, I realize your example is devoid of context, but I noticed the > link doesn''t have any associated text (e.g., new Element(''a'', { href: > ''#'', target: ''_blank'' }).insert(''click me!'')). If that''s also the case > in the actual code, that could be your problem. > > Although, as long as you''re using JS to add "open in new window" > functionality anyway, it''s more standards-friendly to add an event > handler as previously described. > > :Dan Dorman > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---