Jump to content

Recommended Posts

Posted

I'm attempting to learn CSS and XHTML by retooling one of my sites. I have it to the point that it is valid with transitional XHTML, but not strict. I have no problem using transitional on my site, but for learning, I'd like to know the differences. :(

 

I'm only getting one error at the moment, but I don't know what to do with it.

 

In my page, I use target="_blank" to have links to other sites open in a new window as opposed to having the person leave my site. Apparantly this is an old attribute and is no longer valid. I'm sure I just don't know where to look yet, but what is the new attribute for what I want to do? (Or what do I put in the css to make it open in a new window.)

Posted

Ugh... everything I'm looking at sugests using javascript to open new windows. ;) Anyone know of another way or shall I simply be sticking to transitional xhtml for now. :( Since this was my only error with strict, I'm not too worried about it.

Posted

Unfortunately (or fortunately, depending on your opinion of the matter), the XHTML Strict DTD has removed all references to "target" from any anchor tags. This means that all of the following would be invalid if you coded according to the Strict definition.

<a href="..." target="_blank">

<a href="..." target="_parent">

<a href="..." target="_self">

<a href="..." target="_top">

<a href="..." target="name_of_your_window">

 

Basically, what I'm trying to say is that if it's really important to you to open the link in another window, you'll have to use Javascript to open a new window. You run a slight risk, however, that a user may have javascript disabled on their local machine and will never be able to see the contents of the link.

 

I would do one of two things in this situation (assuming you want and/or need to use the XHTML Strict DTD).

(1) If you need the links to open in a new window, notify the user that they need to make sure Javascript is enabled before clicking the link.

(2) Adhere to the Strict DTD but notify the user that if they wish to return to your web site, they'll need to use their browser's "back" button.

Posted

Just like Kasey said, XHTML Strict has no 'target' attribute for anchors (links) - my thanks to the kind souls who decided that! :goof: Thumbs Up

 

Can you tell I hate pop up windows? :P

And because of that, I have one more reason to love Mozilla Firefox ;)

 

Anyway, here's some nice reading about that:

http://www.simplebits.com/notebook/2004/05/06/sq.html

 

That site has one of my favorite designs, by the way ;)

Posted

The main thing is that XHTML 1.1 Strict doesn't support frames. No frames, no targets.

 

I use something like this in my anchors when I'd like to open a new window:

 

><a href="page.html" onClick="window.open('page.html');return false">page.html</a>

 

For those browsers that support javascript (and have it enabled), the onclick will happen - the new window will open, and 'false' will be returned, so that the page doesn't move. If you don't do this, you'll get a new window and you'll get a new page in the existing window.

 

For those browsers who don't support javascript, or don't have it enabled, the onclick event is ignored - so the new page opens in the existing window. While it may mean some people don't get a new window, it will work in many cases - and more importantly, it will degrade gracefully, so if someone doesn't have javascript enabled (or have it at all), they can still get to the link.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...