Forum: Redcloth Opening links in a new window

6eb647ceaf71499931542f2a83710f44?d=identicon&s=25 Asfand yar Qazi (ayqazi)
on 2009-08-26 20:19
(Received via mailing list)
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
1a1551a3a11e750cd46e5699cb175941?d=identicon&s=25 Rodrigo Rosenfeld Rosas (Guest)
on 2009-08-28 13:23
(Received via mailing list)
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.
6eb647ceaf71499931542f2a83710f44?d=identicon&s=25 Asfand yar Qazi (ayqazi)
on 2009-08-28 15:27
(Received via mailing list)
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@yahoo.com.br>:
A50dcaaf8e545e6cc1fb4e32919be6ad?d=identicon&s=25 Jason Garber (jgarber)
on 2009-08-29 09:09
(Received via mailing list)
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.
6eb647ceaf71499931542f2a83710f44?d=identicon&s=25 Asfand yar Qazi (ayqazi)
on 2009-08-29 11:31
(Received via mailing list)
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@jasongarber.com>:
D3c9a4e663c77df1fe4888da3ba85bcc?d=identicon&s=25 * William (Guest)
on 2009-09-03 13:18
(Received via mailing list)
Hi :-)

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 Qazi <ayqazi@gmail.com>

> 2009/8/29 Jason Garber <jg@jasongarber.com>:
> > I'd say using Javascript instead of target="_blank" is a good call.  May
> I
>

aloha,
        \_w_/
This topic is locked and can not be replied to.