Hi, Short question: How do I create links that open in a new browser window/tab without resorting to raw HTML? Long question: So I want to have links like so: <a href=''http://wherever.com'' rel=''external''>This is a link</a> I''ve got some javascript that runs on every page after it is loaded and translates the rel=''external'' into target=''_blank''. Stupid XHTML 1.0 strict doesn''t allow target=''_blank'' even though all browsers support it, so the javascript magic is purely so my html is validated against it. I know I can just put raw HTML in, but I don''t want to. There has to be an easier way, using the lovely RedCloth syntax. Help? Thanks
Em 26-08-2009 18:18, Asfand Yar Qazi escreveu:> Hi, > > ... > I''ve got some javascript that runs on every page after it is loaded > and translates the rel=''external'' into target=''_blank''. Stupid XHTML > 1.0 strict doesn''t allow target=''_blank'' even though all browsers > support it, so the javascript magic is purely so my html is validated > against it. > >Hi Asfand, sorry I don''t know the answer, but I''m curious. Why do you need it to be validated as XHTML strict? The idea behind XHTML strict is to make your site accessible. Using Javascript per se makes your site innacessible (more than using target="_blank"), since Javascript is not standardized. And what do you mean by "all browsers"? Do you know there are console browsers, brailer browsers, cell phones, etc? Opening a new page is not always clear in all environments. It is easy to understand that a knew page is open when a normal person stands in front of a common desktop browser. But XHTML stricts aims at accessibility and that is why the target attribute is not allowed. If you are not concerned about making your site accessible to blind people or mobile users, than you should not be using XHTML Strict, in my opinion. Choose one that allows target attribute instead of using Javascript where you don''t need it. Or does your client asked the pages to be validated with XHTML Strict? If so, and if they are concerned about accessibility, the approach you are taking will not be accepted by it. But if the client just doesn''t know what XHTML Strict mean, then feel free to continue doing it that way. Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/
In other words it''s not possible - that''s all I needed to know :-) If a person''s browser does not support opening links in a new window, then the link will simply open in the same window. In other words, by conforming to XHTML 1.0 Strict, the functionality is not reduced, just a bit of convenience goes away. But for the majority of my users'' browsers, the bit of extra convenience is added to allow the link to open in a new window. 2009/8/28 Rodrigo Rosenfeld Rosas <lbocseg at yahoo.com.br>:> Em 26-08-2009 18:18, Asfand Yar Qazi escreveu: >> >> Hi, >> >> ... >> I''ve got some javascript that runs on every page after it is loaded >> and translates the rel=''external'' into target=''_blank''. ?Stupid XHTML >> 1.0 strict doesn''t allow target=''_blank'' even though all browsers >> support it, so the javascript magic is purely so my html is validated >> against it. >> >> > > Hi Asfand, sorry I don''t know the answer, but I''m curious. Why do you need > it to be validated as XHTML strict? > > The idea behind XHTML strict is to make your site accessible. Using > Javascript per se makes your site innacessible (more than using > target="_blank"), since Javascript is not standardized. > > And what do you mean by "all browsers"? Do you know there are console > browsers, brailer browsers, cell phones, etc? Opening a new page is not > always clear in all environments. It is easy to understand that a knew page > is open when a normal person stands in front of a common desktop browser. > But XHTML stricts aims at accessibility and that is why the target attribute > is not allowed. If you are not concerned about making your site accessible > to blind people or mobile users, than you should not be using XHTML Strict, > in my opinion. Choose one that allows target attribute instead of using > Javascript where you don''t need it. > > Or does your client asked the pages to be validated with XHTML Strict? If > so, and if they are concerned about accessibility, the approach you are > taking will not be accepted by it. But if the client just doesn''t know what > XHTML Strict mean, then feel free to continue doing it that way. > > Rodrigo. > __________________________________________________ > Fa?a liga??es para outros computadores com o novo Yahoo! Messenger > http://br.beta.messenger.yahoo.com/ > _______________________________________________ > Redcloth-upwards mailing list > Redcloth-upwards at rubyforge.org > http://rubyforge.org/mailman/listinfo/redcloth-upwards >
I''d say using Javascript instead of target="_blank" is a good call. May I suggest, then, just using a CSS class to denote which should be external? Any JS library should be able to observe all A tags of a certain class and make them open in a new window. On Aug 26, 2009, at 2:18 PM, Asfand Yar Qazi wrote:> Hi, > > Short question: > > How do I create links that open in a new browser window/tab without > resorting to raw HTML? > > Long question: > > So I want to have links like so: > > <a href=''http://wherever.com'' rel=''external''>This is a link</a> > > I''ve got some javascript that runs on every page after it is loaded > and translates the rel=''external'' into target=''_blank''. Stupid XHTML > 1.0 strict doesn''t allow target=''_blank'' even though all browsers > support it, so the javascript magic is purely so my html is validated > against it. > > I know I can just put raw HTML in, but I don''t want to. There has to > be an easier way, using the lovely RedCloth syntax. Help? > > Thanks > _______________________________________________ > Redcloth-upwards mailing list > Redcloth-upwards at rubyforge.org > http://rubyforge.org/mailman/listinfo/redcloth-upwards
That''s actually a brilliant idea. I didn''t think of that. It makes perfect sense. I was using the guidelines of some article that said use rel=external instead of target=_blank. On the other hand, having thought about what Rodrigo said, and read a few articles, I think I might just stop opening links in a new window anyway. It confuses or annoys users apparently. Thanks all 2009/8/29 Jason Garber <jg at jasongarber.com>:> I''d say using Javascript instead of target="_blank" is a good call. ?May I > suggest, then, just using a CSS class to denote which should be external? > ?Any JS library should be able to observe all A tags of a certain class and > make them open in a new window. > > On Aug 26, 2009, at 2:18 PM, Asfand Yar Qazi wrote: > >> Hi, >> >> Short question: >> >> How do I create links that open in a new browser window/tab without >> resorting to raw HTML? >> >> Long question: >> >> So I want to have links like so: >> >> <a href=''http://wherever.com'' rel=''external''>This is a link</a> >> >> I''ve got some javascript that runs on every page after it is loaded >> and translates the rel=''external'' into target=''_blank''. ?Stupid XHTML >> 1.0 strict doesn''t allow target=''_blank'' even though all browsers >> support it, so the javascript magic is purely so my html is validated >> against it. >> >> I know I can just put raw HTML in, but I don''t want to. ?There has to >> be an easier way, using the lovely RedCloth syntax. ?Help? >> >> Thanks >> _______________________________________________ >> Redcloth-upwards mailing list >> Redcloth-upwards at rubyforge.org >> http://rubyforge.org/mailman/listinfo/redcloth-upwards > > _______________________________________________ > Redcloth-upwards mailing list > Redcloth-upwards at rubyforge.org > http://rubyforge.org/mailman/listinfo/redcloth-upwards >