Forum Moderators: open

Message Too Old, No Replies

XHTML Strict

No target attribute

         

Birdman

6:59 pm on Feb 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does anyone know an alternate way of opening links in a new window without using JS or the target attribute?

Seems target is not allowed in XHTML strict.

MWpro

7:30 pm on Feb 2, 2003 (gmt 0)

10+ Year Member



Good question, you may have to go with the javascript unfortunately.

<a href="newpage.html" onclick="window.open('newpage.html'); return
false;">Link Name Here</a>

Or you can change your doctype from strict to transitional and it should work.

bird

8:17 pm on Feb 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you sure that the target attribute isn't allowed in XHTML strict?

It's listed in the XHTML 1.0 Strict DTD [w3.org]:

<!--================== The Anchor Element ================================-->

<!-- content is %Inline; except that anchors shouldn't be nested -->

<!ELEMENT a %a.content;>
<!ATTLIST a
%attrs;
%focus;
charset %Charset; #IMPLIED
type %ContentType; #IMPLIED
name NMTOKEN #IMPLIED
href %URI; #IMPLIED
hreflang %LanguageCode; #IMPLIED
rel %LinkTypes; #IMPLIED
rev %LinkTypes; #IMPLIED
shape %Shape; "rect"
coords %Coords; #IMPLIED
target %FrameTarget; #IMPLIED
>

c3oc3o

12:51 am on Feb 3, 2003 (gmt 0)

10+ Year Member



"Target" is...
* non-semantic: it means nothing, like <font> and other deprecated tags
* graphical-browser-specific: What should a voice browser or a mobile phone do with it?
* inflexible: No "open in new tab"-value for tabbed browsers
* an attribute that takes control about a user's browser windows away from him: There's no way to override it, at least in the most popular browser.

I've stopped using it myself outside of frames.
(Then again, I don't run any commercial websites that need to keep visitors on the page as long as possible to suck money out of them...)

lorax

3:33 am on Feb 3, 2003 (gmt 0)

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



bird,
Not sure where you got that DTD/Element def from. ;)

<!--================== The Anchor Element ================================-->

<!-- content is %Inline; except that anchors shouldn't be nested -->

<!ELEMENT a %a.content;>
<!ATTLIST a
%attrs;
%focus;
charset %Charset; #IMPLIED
type %ContentType; #IMPLIED
name NMTOKEN #IMPLIED
href %URI; #IMPLIED
hreflang %LanguageCode; #IMPLIED
rel %LinkTypes; #IMPLIED
rev %LinkTypes; #IMPLIED
shape %Shape; "rect"
coords %Coords; #IMPLIED
>

Comes from [w3.org...]

No target allowed.

bitstream

11:10 am on Feb 3, 2003 (gmt 0)

10+ Year Member



Discovering that target is no longer a valid attribute has been a pain. My web apps rely on target in order to direct output to frames or new windows. In ordrer to achieve strict standards compliance I've had to restore a lot of this functionality using javascript.

I have tried my best to find out why it was removed from Strict, but none of the explanations that I have seen have convinved me that this was a smart move.I mean, if you can accomplish the same thing with javascript window.open and location.href then why take this, IMO very useful feature out of the DTD?

Are they going to outlaw Javascript next?

lorax

2:35 pm on Feb 3, 2003 (gmt 0)

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



Hello bitstream and welcome to WebmasterWorld!

I know it's a pain but I've not only gotten used to it, but rather enjoy it now. I'm a reformed javascript addict btw.

The guidelines do seem to be pushing simplicity and I for one and all for it. I've long since disabled javascript and pop-ups since I personally find them annoying. And since I do, I've taken the "do unto others as you would have them do unto you" approach - hence no javascript or popups on my sites.

Will they ban JS? I don't think so. While I ranted about JS a few moons ago I know there are some useful attributes to it. It is a script language and I suspect it will be around for quite a while yet. Heck, DOS script commands are still in use. :)

bird

5:00 pm on Feb 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bird,
Not sure where you got that DTD/Element def from.

I provided a link to the relevant page. The problem is, that this same page displays the DTDs for all three of XHTML-1.0 Strict, Transitional, and Frameset. Looks like I forgot to check that the excerpt is really from the strict version... ;)

Note that both the Transitional and Frameset definitions still allow to send anchors to a target. The first for compatibility reasons, the second because you can't do frames without.

Ok, now that I've learned that, I have to say that I'm really glad that it won't be possible for a web site to open a new window on my desktop with standard XHTML.

lorax

5:24 pm on Feb 3, 2003 (gmt 0)

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



Sorry bird,
I missed that URL.

G.

korkus2000

6:15 pm on Feb 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So with a strict DTD you can only open a new window with JavaScript, or is there another way? I think it is understandable not to have the target attribute since there is a frameset DTD.

lorax

6:33 pm on Feb 3, 2003 (gmt 0)

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



Korkus2000 - correct. XHTML 1.0 supports:

<!ENTITY % events
"onclick %Script; #IMPLIED
ondblclick %Script; #IMPLIED
onmousedown %Script; #IMPLIED
onmouseup %Script; #IMPLIED
onmouseover %Script; #IMPLIED
onmousemove %Script; #IMPLIED
onmouseout %Script; #IMPLIED
onkeypress %Script; #IMPLIED
onkeydown %Script; #IMPLIED
onkeyup %Script; #IMPLIED"
>

DrDoc

7:40 pm on Feb 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In ordrer to achieve strict standards compliance I've had to restore a lot of this functionality using javascript.

Well, you can always make sure your pages validate against the strict DTD (without the target attribute) .. Then add target, and change the DTD to transitional ..

bitstream

9:56 pm on Feb 3, 2003 (gmt 0)

10+ Year Member



I could have gone with Transitional and kept target, but going for strict compliance became a challenge that I couldn't resist. What I don't understand, I guess, is that since target is not layout related why not allow it? I hate pop-ups as much as the next guy, but in some cases they do have a place, and trying to put up roadblocks like this is just going to mean that people like me who need pop-ups for various reasons will use other means to accomlish it. Therefore I can't see that W3C has accomplished anything other than making it harder to comply with the standard and this could lead to more non-standard compliant sites. I don't think that is what W3C would want.

As I see it, if the reason for removing target is to discourage frames and pop-ups then any javascript methods that do the same must also be disallowed, otherwise what's the point?

bird

10:10 pm on Feb 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How does the definition of a specialized DTD for framed pages discourage the use of frames?

To create a useful popup, you need Javascript anyway. The target attribute in a link will simply open the page in a new window, which normally has the same size as the previous one, and will completely obscure it in many cases. Most of the time, you want a popup to be significantly smaller than that. Being able to just stack arbitrary numbers of equally sized windows on top of each other isn't a very helpful HTML feature.

Birdman

2:16 pm on Feb 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've been reading about xhtml modularization [w3.org] since starting this thread. I can't figure out how to implement it, but it looks like you can custom design your dtd.

Thanks for all the replies.