Click to See Complete Forum and Search --> : XHTML 1.1 --> target attribute


jasondubya
12-30-2003, 07:54 PM
I am in the process of developing a new site. The plan is to have the site comply with the XHTML 1.1 Recommendation. Upon validating the documents that I have, I receive the following error:

Error: there is no attribute target for this element (in this HTML version)
I need to use the target attribute, or something similar, to cause the browser to open the link in a new browser window. Is there an attribute for the a element in XHTML 1.1 that will do this?

pyro
12-30-2003, 08:10 PM
Nope. You can, however, use JavaScript to open it in a new window:

<a href="http://www.w3.org/" onclick="window.open(this.href); return false;">W3C</a>

fredmv
12-30-2003, 10:50 PM
Also:<a href="http://www.google.com/" onclick="target='_blank';">Google</a>

Sux0rZh@jc0rz
01-02-2004, 02:28 AM
can u open a window using php? if so, could one do action="open.php" then have open.php open the new window and ergo, it be valid plus work for all users instead of working for 87% like JS?

AdamGundry
01-02-2004, 05:29 AM
No, PHP runs on the server-side and hence cannot open new windows, which is an inherently client-side activity. AFAIK, the best method is pyro's, which will open a new window if JS is enabled and use the current one if it is not.

Adam

Robert Wellock
01-05-2004, 12:51 PM
Alternatively you use the eXtensibility aspect of XHTML 1.1 and reintroduce the target but it was removed for a good reason.

Paul Jr
01-05-2004, 03:18 PM
Originally posted by Robert Wellock
it was removed for a good reason.
Just curious, but what would that reason be?

fredmv
01-05-2004, 03:21 PM
Originally posted by Paul Jr
Just curious, but what would that reason be? Two things come to mind: It causes accessibility problems (http://www.diveintoaccessibility.org/day_16_not_opening_new_windows.html). Users should be able to decide whether they want links to open in a new window or not.

Paul Jr
01-05-2004, 03:42 PM
Originally posted by fredmv
Two things come to mind: It causes accessibility problems (http://www.diveintoaccessibility.org/day_16_not_opening_new_windows.html). Users should be able to decide whether they want links to open in a new window or not.
Thanks for the linkage, and I completely agree. I don't like it when people have new windows opening all over the place.

tbeach44
02-15-2004, 04:19 PM
There are some times when a new window is desirable and I recently ran across some tags from PayPal for insertion of their logo that included the target attribute. So if I wanted to include the logo I would have to alter their tags but I couldn't find an alternative in xhtml. However I believe that is only true if you validate as strict. According to what I read it will work in xhtml as transitiional. In my case the logo wasn't that important and I scrapped it.
I am surprised that this is not an option to developers using xhtml and validating strict however. There are definately times when a new window is desirable.

fredmv
02-16-2004, 02:54 AM
Originally posted by tbeach44
I am surprised that this is not an option to developers using xhtml and validating strict however.Technically, it is. Did you read this entire thread? You can either emulate it using JavaScript and thus still being degradable, or use the extensibility aspect of XHTML and add the attribute yourself as Robert has already implied.

tbeach44
02-16-2004, 03:38 PM
Originally posted by fredmv
, or use the extensibility aspect of XHTML and add the attribute yourself as Robert has already implied.

Could you explain that please.

Robert Wellock
02-17-2004, 09:00 AM
I can explain it visit http://www.xhtmlcoder.com/beck.htm click on one of the movie links watch the movie view the page source.

Notice I have used <embed /> find the that page address; shove the page containing the embedded QuickTime Movie through the W3C Validator and notice it validates even though <embed /> is not an official W3C element.

In other words I have added a new element called <embed /> to XHTML 1.0 Strict; eXtending by using the Black Arts of EBNF and DTD hence applying eXtensibility.

gizmo
02-19-2004, 12:23 PM
I am in the process of converting one of my sites to xhtml1.0 strict. For the <a> tag, w3schools states that there is no difference between html and xhtml, yet several pages which use the line:
<a href="index.html" target="_top">Home Page</a> no longer validate with the error "You have used an attribute with an element that is defined not to have that attribute" yet the example given is
<a href="http://www.w3schools.com" target="_blank">W3Schools</a>
Does this mean that for xhtml1.0 that w3schools is incorrect ?

MrPunkin
02-19-2004, 05:23 PM
Jason,

I went though the same problem when creating my site ;)

I decided to ditch it in the long run though. IM me sometime... im interested in seeing what your working on.


Bryan

tbeach44
02-19-2004, 07:50 PM
Originally posted by gizmo
Does this mean that for xhtml1.0 that w3schools is incorrect ?

If you look at the xhtml reference on the w3shools site it will list target as an attribute of <a> but in the last column, DTD, it specifies only T (transitional) and F (frameset) but not S (strict).

Robert Wellock
02-20-2004, 08:08 AM
It wouldn't surprise me it the code within w3schools is incorrect the "XHTML Quiz" http://www.w3schools.com/xhtml/xhtml_quiz.asp is wrong I'll give £10.00 to the first person that tells me which question answer they have got wrong, and why - it's any easy one if you know XHTML.

But in your instance they weren't in either case the W3C has the correct information about DTD.

Robert Wellock
02-23-2004, 09:34 AM
Sorry Folks the Competition has now expired and the £10.00 is not on offer anymore - I gave you two days.

Paul Jr
02-23-2004, 04:12 PM
Lol. So you gonna tell us what it is? ;)

Robert Wellock
02-24-2004, 07:41 AM
4. HTML will be replaced by XHTML
You answered:
False
Wrong Answer!

XHTMLCODER: W3Schools WRONG

XHTML will not replace HTML 4.01 because they are two different markup Languages XHTML is an application of XML or reformulation of HTML 4.01 not a complete replacement. SGML is the parent of HTML and XML is a subset of SGML.

Additionally there were about three other spurious questions that were incorrect with reference to XHTML 1.0 although I assume they were relating to vanilla XHTML 1.0 without having considered the eXtensibilty aspect.

So if you said Q4. last weekend you would have had £10.00.

Paul Jr
02-24-2004, 07:35 PM
I wasn't ever sure of that one question. I always assumed it would replace HTML. I mean, there was XHTML 1.0, 1.1, and coming up 2.0 (I think), so... why hasn't there been an HTML 5, or some equivalent version? It sure looks like XHTML is replacing HTML.

Robert Wellock
02-25-2004, 11:52 AM
XHTML 1.1 and 1.0 are also different whereas HTML 4.01 was a replacement for HTML 4.0 there is no HTML 5.0 because its lifespan ended in favour of XHTML 1.x but it not a replacement in the sense of how they posed the question.

They also had something like WIDTH="80" and width="80" both are valid XHTML but if you were working from the standard XHTML 1.0 W3C DTD without using the eXtensibility the latter would be the more correct answer.