From: Adam Richardson on
On Fri, May 14, 2010 at 4:49 PM, Ashley Sheridan
<ash(a)ashleysheridan.co.uk>wrote:

> On Fri, 2010-05-14 at 13:18 -0400, Adam Richardson wrote:
>
> On Fri, May 14, 2010 at 8:59 AM, Andrew Ballard <aballard(a)gmail.com> wrote:
>
> > On Thu, May 13, 2010 at 5:18 PM, Ashley Sheridan
> > <ash(a)ashleysheridan.co.uk> wrote:
> > > On Thu, 2010-05-13 at 17:13 -0400, David Mehler wrote:
> > >
> > >> Hello,
> > >> I want to open an external link in a new window, i know i can do this
> > >> with xhtml, but only with the transitional dtd, which i'm not using. I
> > >> was wondering if php could pull this off?
> > >> Thanks.
> > >> Dave.
> > >>
> > >
> > >
> > > No. PHP is on the server, not the client-side. If you can't use
> > > something like target="_blank" in your xhtml, then consider using
> > > Javascript. It's not the ideal solution, as it won't work where
> > > scripting is disabled or not available.
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> >
> > It may or may not be the "ideal" solution, but I'm pretty sure it is
> > considered the "correct" solution going forward. I recall reading
> > somewhere that things like controlling the "target" for a link are
> > considered behavior rather than part of the document's semantic
> > structure, and therefore belong in scripting rather than markup under
> > XHTML. That makes sense given that one of the goals of XHTML is
> > structured documents that can be consumed by multiple services,
> > including but not exclusively web browsers.
> >
> > This also has the side effect that the decision of whether to open a
> > link in the current window or a new window/tab belongs to the viewer
> > instead of the author, which some argue is exactly as it should be.
> >
> > Andrew
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> I'd avoid the target attribute, as it's deprecated in the strict versions
> (and I'd avoid it for the reasons Andrew mentioned.)
>
> For reading, here's a nice resource to start with:http://www.456bereastreet.com/archive/200603/the_target_attribute_and_opening_new_windows/
>
> Adam
>
>
>
> There are still valid reasons to use it. On my own site for example, and
> links which lead outside of my site open up in a new tab/window. I link to a
> lot of other external sites often in my blog entries, and I think it's valid
> that these links open up in new tabs/windows so that my site is left open
> when they read the rest of the article.
>
> I guess I could add some form of indication that the link will open up in a
> new window though.
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
The resource I suggested was focused on the use of the target attribute to
open a new window.

Yes, there are situations where opening a new window/tab are appropriate
(but, as you mentioned, you should always try to provide feedback that
clicking the link will open a new window.) However, using javascript to
open new windows provides a solution that validates for both strict and
transitional documents AND separates behavior from content.

Adam

--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com
From: Michiel Sikma on
On 14 May 2010 22:49, Ashley Sheridan <ash(a)ashleysheridan.co.uk> wrote:

>
> There are still valid reasons to use it. On my own site for example, and
> links which lead outside of my site open up in a new tab/window. I link
> to a lot of other external sites often in my blog entries, and I think
> it's valid that these links open up in new tabs/windows so that my site
> is left open when they read the rest of the article.
>
> I guess I could add some form of indication that the link will open up
> in a new window though.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
I don't entirely agree that the target attribute should be avoided, or that
you absolutely need to use Strict XHTML rather than Transitional. There
really aren't that many differences between them. Yes, a lot of legacy
elements were removed, but those that program in valid XHTML tend to not use
them anyway.

The real reason why target is a little ill-conceived is because not all
target devices are able to use it in a valid way, e.g. phones with simple
web browsers. But if it was never your intention to support those devices,
using Transitional and the target attribute really isn't an issue.

Michiel
From: Andrew Ballard on
>> On Fri, May 14, 2010 at 8:59 AM, Andrew Ballard <aballard(a)gmail.com> wrote:
>>
>> > This also has the side effect that the decision of whether to open a
>> > link in the current window or a new window/tab belongs to the viewer
>> > instead of the author, which some argue is exactly as it should be.
>> >
>> > Andrew

On Fri, May 14, 2010 at 4:49 PM, Ashley Sheridan
<ash(a)ashleysheridan.co.uk> wrote:
> There are still valid reasons to use it. On my own site for example, and
> links which lead outside of my site open up in a new tab/window. I link
> to a lot of other external sites often in my blog entries, and I think
> it's valid that these links open up in new tabs/windows so that my site
> is left open when they read the rest of the article.
>
> I guess I could add some form of indication that the link will open up
> in a new window though.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Obviously it is up to you as the site author, but then that was part
of the point I was trying to make above. Authors frequently make links
to "external" material open in a new window because they don't want
the user to navigate away from their own site. However, there are many
who would argue that the target of a link is a decision that belongs
to the viewer. In most browsers, one has the choice with any regular
link to either click it and open it in the same window/frame as the
referring document, or open the context menu (right-click, etc.) for
the link and open it in a new tab/window. If the site author specifies
target="_blank", the author has removed one of those options from the
viewer. I get annoyed by sites that use
href="javascript:window.open('someurl')" specifically because it
prevents me from choosing to open the link in a new tab.

Besides, as Adam said, more and more web browsing is being done on
mobile devices and other platforms that don't support multiple
"windows". In these environments, the idea of a link target no longer
has meaning.

For what it's worth, here is a sample page that shows one way to
address the OP's question of duplicating the functionality of "target"
on links while still being valid XHTML. And yeah ... I know someone
will blast me for how much code it took to duplicate a simple
target="_blank" attribute. :-) I didn't test it extensively (just
tried it in Firefox and IE7) but I believe it degrades pretty well, it
simulates target pretty closely, and it validates.

http://pastebin.com/Q3MrWBKi


Andrew
First  |  Prev  | 
Pages: 1 2
Prev: Parse question
Next: Append Dom Document