Opening links in a new window

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:

This is a link

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 Q. 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.

In other words it’s not possible - that’s all I needed to know :slight_smile:

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 R. [email protected]:

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.

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 G. [email protected]:

Hi :slight_smile:

javascript is the better option. For the user-centre view, I’m pissed
off
by links that make new windows on the same site. If someone jumps me to
a
‘side bar’, ‘note’ or ‘reference’, then I might prefer a new window if
it
is ‘substantial’ and a pop-up or overlay if it is a small description
(for
example).

What if you are not sure about someone who is NOT me? You could bring
up an
overlay pop-up and ask if he wants links opened in a new window or as
overlays and record that preference.

Just a thought

Take care,
_w_/

2009/8/29 Asfand Yar Q. [email protected]

2009/8/29 Jason G. [email protected]:

I’d say using Javascript instead of target=“_blank” is a good call. May
I

aloha,
_w_/