Forum Moderators: open

Message Too Old, No Replies

4.01 strict dtd and attribute 'target'?

         

PsychoTekk

11:12 am on Aug 17, 2003 (gmt 0)

10+ Year Member



hi, i'm pretty confused about the validation results
for a 4.01 strict dtd page, it says that
the attribute 'target' was not alowed in
the <a> element anymore? the spec doesn't list it
and the 'defined elsewhere' just points
to the frames section. so what do i have to do
about the target attribute if i want a page
to open in a new window?

thanks!

MonkeeSage

11:57 am on Aug 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, others interpret the deprecation of the target attribute differently and have different ways of getting around it (or just keep using it, since all the browsers still support it), but I personally interpret it to mean that opening new windows is a task and needs to be done in the tasking standard--JavaScript. :)

<a href="http://somewhere.com/" title="A link somewhere"
onclick="void(window.open(this.href,'','')); return false;">Link Text</a>

Ps. Target is the second param passed to the window.open() method, you can also just pass null ('') as in the example above to open a new window.

Jordan

PsychoTekk

1:12 pm on Aug 17, 2003 (gmt 0)

10+ Year Member



thanks Jordan, but javascript can be turned off
so i hope there is some other solution?

TheWhippinpost

3:21 pm on Aug 17, 2003 (gmt 0)

10+ Year Member



You can declare the target module of the xhtml DTD, there is a tutorial here [juicystudio.com] though admittedly I couldn't get it to work, if you have any luck lemme know.

MonkeeSage

12:44 am on Aug 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PsychoTekk:

Yes, JS can be turned off. That is why I set up the example the way I did:

JS off = follow the link in the same window (acts like regular link).
JS on = open it in the target window w/ the onclick handler.

That way the site is 100% accessible, JS or not.

Ps. 98-99% of users have JS enabled.

Pss. CSS can also be disabled (or forcibly overrided) in a couple of the major browsers (Mozilla / Opera) but that doesn't stop us from designing for the 99% with it enabled.

Jordan

MatthewHSE

2:09 pm on Aug 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Personally, I think the target attribute should be allowed in Strict. What about all the popup blockers that stop new windows opened by JavaScript? Admittedly, the good ones don't stop requested popups, but there are a lot of bad ones out there too, either free or cheap and all claiming to be the best.

Target="_blank" is also less code than opening the window with JavaScript.

Of course, this is just me talking; I really doubt the W3C will change their standards just because I advised it! :)

Then again, if everyone would only use a tabbed browser instead of IE, and knew how to use it, we could leave new windows/tabs totally up to the user!

hafnius

3:10 pm on Aug 19, 2003 (gmt 0)

10+ Year Member



I just finished a site in xhtml strict and in an article i found a very clean javascript method of opening links in a new window:

In an external .js file i have:


function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;

and the links that should open in a new window gets the fake attribute "external":


<a href="http://www.foo.com" rel="external">

All links with this fake attribute opens in a new window and it validates.

On a side note i think i heard that the target attribute would be included in the DTD for XHTML again in an upcoming version, but i am not sure.

Kind Regards
Hafnius

Albhar

7:00 pm on Aug 19, 2003 (gmt 0)

10+ Year Member



I still have to find a good reason to use target (i am not talking about framesets which hopefully will fade out quickly, am i dreaming? surely :-)). And as a user I find target="_blank" really irritating, like some big brother telling how I should use my browser.

g1smd

11:05 pm on Aug 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I used to like opening a new page in a new window.

Now that I use tabbed browsing with Mozilla I find target="_blank" quite irritating, as I like to open pages in a new tab instead.

Purple Martin

6:43 am on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I like internal links (to pages within the same site) to open in the same window, and external links (to other sites) to open in a new window. So I have one window per site. But hey, it's all about personal preferance, and there are gong to be many opinions on something like this.

Albhar

5:28 pm on Aug 20, 2003 (gmt 0)

10+ Year Member



Having internal links in the same window and external ones in another may work for you (i find it quite sensible even if i don't browse like that) but it's a user decision.

Having some so-called webmaster telling me how i should browser is not a sensible option. Moreover any recent graphical browser,except IE, support natively tab-browsing.

RammsteinNicCage

2:06 am on Aug 21, 2003 (gmt 0)

10+ Year Member



On my site, there's an image gallery with 16 pics per page in a 4x4 square. I have the thumbnails linked to their full sized images and I use the target attribute because I thought that if someone clicks on an image before the entire page loaded and then pressed the back button, the rest of the images wouldn't fully load unless they refreshed. Am I wrong about that? Should I take the targets out?

Jennifer