![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
using the target attribute in XHTML1.1
There's a target module in XHTML1.1 but I've no idea how to use it. I've tried putting all kinds of things in the !DOCTYPE, but the validator either spits out syntax error in the DTD or target isn't an attribute.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted. Got 'Nux?—GNU/Linux and other free software support. It's GNU/Linux, not just Linux. |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 122
Rep Power: 3
![]() |
Ok, first off, you shouldn't be using XHTML1.1 - it is way ahead of its time,
and until IE supports the application/xhtml+xml content type [which, by the way, you are required to serve it as], it is pointless. Now, as for the links, the best way to do this, is using JavaScript. Add a 'rel' attribute to all your links, like so: <a href="#" rel="external">This will open in a new window</a> <a href="#">This will open in the current window</a> <script type="text/JavaScript">
//<![CDATA[
function hookExternalLinks()
{
var links=document.getElementsByTagName('a');
for (var i=0; i<links.length; i++)
{
if (links[i].rel=='external') links[i].target='_blank';
}
}
window.onload=hookExternalLinks;
//]]>
</script>
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet" |
|
|
|
|
|
#4 |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
I really don't care if Trident doesn't support XHTML. Every other modern rendering engine I've come across except Lynx supports it. XHTML1.0's been around since 1999 and 1.1 since 2001; there's no excuse for not supporting it now other than an unmaintained project.
And using rel and that JavaScript instead of directly putting target="_blank" is pointless.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted. Got 'Nux?—GNU/Linux and other free software support. It's GNU/Linux, not just Linux. |
|
|
|
|
|
#5 |
|
Programming Guru
![]() |
a_thing i think he's making a suggestion to help get past xHTML validation...
__________________
|
|
|
|
|
|
#6 |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
But it's still invalid.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted. Got 'Nux?—GNU/Linux and other free software support. It's GNU/Linux, not just Linux. |
|
|
|
|
|
#7 | |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 122
Rep Power: 3
![]() |
Quote:
users just because of your 'ideals', then you are an idiot. Why is setting the target attribute pointless? You asked how to have your links open in new windows while still using strict HTML, and I answered. If you don't want help, don't ask for it. ![]()
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet" |
|
|
|
|
|
|
#8 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 122
Rep Power: 3
![]() |
If you really have a problem setting the target attribute, then you can use
something like this instead. <script type="text/JavaScript">
//<![CDATA[
function hookExternalLinks()
{
var links=document.getElementsByTagName('a');
for (var i=0; i<links.length; i++)
{
if (links[i].rel=='external')
{
links[i].onclick=makeExternal;
links[i].onkeydown=makeExternal;
}
}
}
function makeExternal(event)
{
if ((typeof(event)=="undefined")||(!event))event=window.event;
var lnk=event.target||event.srcElement;
return !window.open(lnk.href);
}
window.onload=hookExternalLinks;
//]]>
</script>--47.
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet" |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 122
Rep Power: 3
![]() |
IE, in its default settings, can't handle the application/xhtml+xml mime
type, and thus brainfarts when it sees it. Have a look at this page in Firefox to see what it is meant to look like, then look at it in IE... ![]() http://garyblue.port5.com/webdev/xhtml/xhtmldoc.html Now, look at this page to see what happens when your XHTML has an error in. Again, the proper result can be seen in Ff, while IE fecks it up. http://garyblue.port5.com/webdev/xht...-xhtmldoc.html <edit> Oh, Ooble deleted his last post while I was typing this up... :/ Nevemind. Nothing to see here - move along people... --47.
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet" |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|