5 replies [Last post]
EssentialBuyerGuides
EssentialBuyerGuides's picture
Offline
Enthusiast
England
Last seen: 17 years 48 weeks ago
England
Joined: 2004-06-25
Posts: 91
Points: 0

I've recently changed a link on a site to open in the same window as the target is not allowed any more, according to the Xhtml Validator over at the W3C.

How would you target a new browser window, especially a pop-up or a new window, without using a Target="_blank" attribute?

Cheers in advance for help. Smile

papakrantz
Offline
Regular
nyc
Last seen: 18 years 9 weeks ago
nyc
Timezone: GMT-5
Joined: 2004-03-25
Posts: 20
Points: 0

this is how i do it....

<a href="http://google.com/" onClick="window.open(this.href, 'popupwindow', 'width=400,height=300,scrollbars,resizable'); return false;">Click me, fool.</a>

be nice.

Man26
Offline
newbie
Last seen: 18 years 3 weeks ago
Joined: 2004-05-06
Posts: 3
Points: 0

Re: this is how i do it....

papakrantz wrote:
<a href="http://google.com/" onClick="window.open(this.href, 'popupwindow', 'width=400,height=300,scrollbars,resizable'); return false;">Click me, fool.</a>

Not is practical, this way is better (for me) Wink
http://www.sitepoint.com/article/standards-compliant-world
Basically use it a .js file and a reference this:
<a href="document.html" rel="external">external link</a>

seb
Offline
Enthusiast
Last seen: 15 years 17 weeks ago
Joined: 2003-09-20
Posts: 208
Points: 0

Target=&quot;_blank&quot; and still xHtml (strict) Valid?

All all of that does is lets your code validate and then butcher it via JS to have a "target" attribute when the page is viewed. Very naughty, don't like that at all. Having a window.open in the function that they give would be better, but is still a bit gash imo.

EssentialBuyerGuides
EssentialBuyerGuides's picture
Offline
Enthusiast
England
Last seen: 17 years 48 weeks ago
England
Joined: 2004-06-25
Posts: 91
Points: 0

Target=&quot;_blank&quot; and still xHtml (strict) Valid?

papa - Thanks for the reply, but I'm not trying to understand the opening of new pop-up windows (maybe I didn't explain enough), but how to target them without using the target attribute.

man26 / Seb Just read the article. For all the effort it seems easier to simply go back to transitional. Tongue

It seems a little backward to say the least. It makes sense for people on PDA's, where new windows aren't possible, but surely, especially given the tabbed browsing now being introduced by mozilla, the standard would maybe move towards something like "_NewTab" or "_ThisTab" . Smile

In the whole company where I work I think there are only 4 out 100 or so people that are actually aware that a CTRL+Click opens a new tab on a link in FireFox, or that a Shift+Click gives a new window in most browsers.

Blargh..

I'd better get playing with the .js then. ;p

Stu
Stu's picture
Offline
Enthusiast
Bristol uk
Last seen: 18 years 18 weeks ago
Bristol uk
Joined: 2004-01-20
Posts: 282
Points: 0

Target=&quot;_blank&quot; and still xHtml (strict) Valid?

You can actually add 'target' back into your dtd

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/tr/xhtml11/DTD/xhtml11.dtd"
[ <!ATTLIST a target CDATA #IMPLIED > ]>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta http-equiv="Content-Type" content="text/xml; charset=UTF-8" />
<title> New Document </title>
</head>
<body>
<div>
<a href="anotherwindow.html" target="_blank">a link in another window</a>
</div>
</body>
</html> 

This is a perfectly legal way to add to the attribute list of an existing tag.
The w3c validator will accept this as valid XHTML1.1 (but even the validator is not perfect. If you remove the <div> </div> it will not validate). :roll:

The downside is that there is a known bug in IE such that the closing '>] 'brackets will be printed on the page. Oh well, you can't have it all.

It's not what you do it's the way that you do it.
So do it with STYLE
http://www.s7u.co.uk