20 replies [Last post]
Gaia
Offline
Regular
in a box
Last seen: 14 years 14 weeks ago
in a box
Joined: 2005-07-12
Posts: 45
Points: 0

hey,

That is what i usually use to send the user to a new window when a link is clicked but XHTML Strict doesn't seem to like that.

How else can i do that?

Fruitcake
Offline
Enthusiast
Perth, Australia
Last seen: 11 years 29 weeks ago
Perth, Australia
Timezone: GMT+8
Joined: 2004-04-12
Posts: 257
Points: 0

target="_blank"

Ideally a fully accessible site should let the users choose themselves if they want to open a link in a new window blah blah blah. Tongue
(no offense intended to accessibility purists).

Having said that you can use a javascript function and pass it the URL. Smile

function open_new(url) 
{
window.open(url);
}

I am Dan, Dan I am.

Gaia
Offline
Regular
in a box
Last seen: 14 years 14 weeks ago
in a box
Joined: 2005-07-12
Posts: 45
Points: 0

target="_blank"

lol that's fair enough Tongue.

I think i'd rather let it be then add extra javascript into the page. :mrgreen:

gleddy
gleddy's picture
Offline
Leader
sydney, australia
Last seen: 11 years 24 weeks ago
sydney, australia
Timezone: GMT+10
Joined: 2004-09-21
Posts: 596
Points: 0

target="_blank"

that's one difference between Strict and Transitional...

I know this keeps some developers from going to the Strict version XHTML due to legacy issues on a site.

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 10 hours 58 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

target="_blank"

There is a 'proper' way to open a linked doc in a new window, that will satisfy everyone but those who despise effect.

<a href="some.html" onclick="return !window.open(this.href);">
  go there</a>
The 'return !' returns the negative value of the result of attempting to open a new window. If the javascript succeeds, returning true, the html link receives false and does not fire. Should the javascript fail to open the window, the result is false, the html link receives true and fires. If there is no javascript, the html link fires.

The onclick event handler exhibits graceful failover, a Good Thing®, and the construct is valid html4/xhtml1 strict.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

firstreflex
firstreflex's picture
Offline
Enthusiast
Brooklyn USA
Last seen: 12 years 33 weeks ago
Brooklyn USA
Timezone: GMT-5
Joined: 2003-10-21
Posts: 104
Points: 0

target=&quot;_blank&quot;

DeprecatedDiva
DeprecatedDiva's picture
Offline
Enthusiast
NW Louisiana
Last seen: 12 years 44 weeks ago
NW Louisiana
Timezone: GMT-6
Joined: 2005-06-12
Posts: 135
Points: 0

target=&quot;_blank&quot;

Shock Coincidence strikes again! Thank you for asking the question Gaia!

Gary, now I gotta learn DOM too? :?

DeprecatedDiva

Anonymous
Anonymous's picture
Guru

Re: target=&quot;_blank&quot;

Gaia wrote:
That is what i usually use to send the user to a new window when a link is clicked but XHTML Strict doesn't seem to like that.
Just a side note that is on topic:

The reason for this is because behavior was removed from markup and left strictly to the DOM. Opening a new window is behavior. Smile

Gaia
Offline
Regular
in a box
Last seen: 14 years 14 weeks ago
in a box
Joined: 2005-07-12
Posts: 45
Points: 0

target=&quot;_blank&quot;

may sound like a complete newbie here Tongue, but what is DOM?

Anonymous
Anonymous's picture
Guru

target=&quot;_blank&quot;

Gaia wrote:
may sound like a complete newbie here Tongue, but what is DOM?

Laughing out loud Wink

DOM = Document Object Model

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 10 hours 58 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

target=&quot;_blank&quot;

DeprecatedDiva wrote:
Shock Coincidence strikes again! Thank you for asking the question Gaia!

Gary, now I gotta learn DOM too? :?
They didn't tell you about javascript and the DOM when you signed up? What about PHP, SQL, and the GIMP? The CLIs for mysql and ssh and scp and ftp? Or about blog, cms, and bb applications? Merchant accounts?

Hah! I'll bet you believed them when they handed you a copy of FrontPage and said you were a WEB DESIGNER.Laughing out loud

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 10 hours 58 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

target=&quot;_blank&quot;

I looked at the sitepoint article that firstreflex cited. It seems a bit of ridiculous overkill to me. Then I saw the mention of the window.open() shortcoming. They say that when using that method 'most' browsers don't properly send referer data. I imagine that's especially important to them.

I was curious, so I ran a little test. I made a page up with a link to another page on my server, using the window.open() method. I then ran `tail -f /var/log/apache/access.log` to watch my access log live.

Run the test in Firefox, referer is shown.

Run test in Opera, referer is shown.

Run test in IE, referer is not shown.

:shrug: I guess IE would be 'most' browsers. Imagine that.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

DeprecatedDiva
DeprecatedDiva's picture
Offline
Enthusiast
NW Louisiana
Last seen: 12 years 44 weeks ago
NW Louisiana
Timezone: GMT-6
Joined: 2005-06-12
Posts: 135
Points: 0

target=&quot;_blank&quot;

kk5st wrote:
DeprecatedDiva wrote:
Shock Coincidence strikes again! Thank you for asking the question Gaia!

Gary, now I gotta learn DOM too? :?
They didn't tell you about javascript and the DOM when you signed up? What about PHP, SQL, and the GIMP? The CLIs for mysql and ssh and scp and ftp? Or about blog, cms, and bb applications? Merchant accounts?

Hah! I'll bet you believed them when they handed you a copy of FrontPage and said you were a WEB DESIGNER.Laughing out loud

cheers,

gary

Nope! They left me in the dark and told me that the mushrooms that I will find growing around me are my normal fodder. It's only when I started asking questions that I realized there is more than mushrooms out there! I've been around long enough that I at least know what most of those acronyms say. What they are and how they function is another matter entirely.

Truth be told on the FP front, the only people who try to hang that sign on my neck that says WEB DESIGNER are my husband and my son.

To this day, I keep getting the feeling that I am going to get booted from all these sites I've signed up on over the last year when they find out that I didn't go to school to learn any of this stuff, but that I did it because I'm a grandma who decided to figure out how that newfangled thang called the internet could be used to sell products that I JUST learned to make back in 2003. Each painful step has led to so many new options that the learning curve gets steeper the longer I stick with it.

I am still trying to wrap my mind around client-side javascripting. Like the individual who recently claimed an inability to learn css, I find I have to be knocked down with a taser (modern equivalent of being struck by lightning) before I grasp tidbits of all these "languages" that I've chosen to learn. W3schools is a patient teacher and w3c is a patient resource. I found them before I found this forum. But this forum has been helping me put things together better than many of the resources I've been gleaning in my quest to understand.

I'm no webmaster and I am honored to be allowed to sit in the back of this classroom and audit this course. I am most honored that I am allowed to ask questions and reply when I actually know something!

Laughing out loud

DeprecatedDiva

Lorraine
Lorraine's picture
Offline
Elder
UK
Last seen: 13 years 9 weeks ago
UK
Timezone: GMT+1
Joined: 2005-01-04
Posts: 1001
Points: 0

target=&quot;_blank&quot;

Ah - so DOM does not stand for Dirty Old Man then :oops:

acardillac
acardillac's picture
Offline
Regular
Pittsburgh, PA
Last seen: 14 years 14 weeks ago
Pittsburgh, PA
Timezone: GMT-4
Joined: 2005-07-14
Posts: 20
Points: 0

target=&quot;_blank&quot;

Ok, I'm really confused. It says you can't use the target="_blank" in strict XHTML, but I did and it works --- but it shouldn't.

DeprecatedDiva
DeprecatedDiva's picture
Offline
Enthusiast
NW Louisiana
Last seen: 12 years 44 weeks ago
NW Louisiana
Timezone: GMT-6
Joined: 2005-06-12
Posts: 135
Points: 0

target=&quot;_blank&quot;

It works but you didn't validate.

DeprecatedDiva

Lorraine
Lorraine's picture
Offline
Elder
UK
Last seen: 13 years 9 weeks ago
UK
Timezone: GMT+1
Joined: 2005-01-04
Posts: 1001
Points: 0

target=&quot;_blank&quot;

Or maybe even more accurately, "What am I not doing that I shoulod be doing?"
I can answer that one. You have not validated the html. W3C offers this somewhat sniffy observation of your use of target="_blank"

Quote:
...ef="http://www.akzonobel.com" target="_blank" class="textlink">akzo Nobel</a>

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

Lorraine
Lorraine's picture
Offline
Elder
UK
Last seen: 13 years 9 weeks ago
UK
Timezone: GMT+1
Joined: 2005-01-04
Posts: 1001
Points: 0

target=&quot;_blank&quot;

:roll: clashed with DD, who knows more than she lets on Wink

acardillac
acardillac's picture
Offline
Regular
Pittsburgh, PA
Last seen: 14 years 14 weeks ago
Pittsburgh, PA
Timezone: GMT-4
Joined: 2005-07-14
Posts: 20
Points: 0

target=&quot;_blank&quot;

oh, ok.

Doesn't some pop-up blockers block the javascript type child windows though?

roytheboy
roytheboy's picture
Offline
Guru
North Wales, UK
Last seen: 6 years 12 weeks ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41

target=&quot;_blank&quot;

acardillac wrote:
Ok, I'm really confused. It says you can't use the target="_blank" in strict XHTML, but I did and it works --- but it shouldn't.

It works because despite the fact that you are trying to code to a strict standard, the page is still being served as good old fashioned HTML, and IE is incapable of handling XHTML anyway. This means that all browsers will treat your pages as HTML, which is why things work that shouldn't. The reason that most of us work to XHTML standards is so that our sites will be ready and error-free if and when Microsoft ever decides to include an XHTML parser in a future version of IE. This issue runs a lot deeper than these few lines but you can read this thread if you want to know more > http://www.csscreator.com/css-forum/ftopic10975.html Wink

Life's a b*tch and then you die!

gleddy
gleddy's picture
Offline
Leader
sydney, australia
Last seen: 11 years 24 weeks ago
sydney, australia
Timezone: GMT+10
Joined: 2004-09-21
Posts: 596
Points: 0

target=&quot;_blank&quot;

some browsers do block javascript pop-ups... (I always block them) so if it's essential information you may want to consider not using popups.