Breaking the Web!! Breaking the Web!!
June 14, 2005 6:36 AM   Subscribe

Which will break first: target=”_blank” or the JavaScript hack meant to replace it?

I am a technical advisor for a small academic press. They are putting out a CD containing some web pages to accompany a book and possibly to give/sell in conjunction with an exhibit. The work mainly features large full-color photographs of the objects in the book and exhibit.

My primary concerns when working on these projects are compatibility and longevity. Since these are web pages on CD, I want them to work on as many machines as possible now and as many browsers as possible in the future. Since the pages are on CD there is no opportunity to update the code in the future as browsers change. Right now my main tool to try and ensure future compatibility is to make sure the pages conform to the most current standards, and the best standard right now is XHTML Strict 1.0. (I understand that not all current browsers do all that XHTML Strict asks, but that is not an issue with the subset of tags I am using on this project, so not a problem.)

However… the editor of the CD wants to have many links (to large images) open in new windows. XHTML Strict does away with the target=”_blank” tag for anchors, and the only workaround involves using JavaScript. This solution seems a little problematic to me for my application (and overly burdensome!). So I ask the collective wisdom of AskMe, which will break first, target=”_blank” or the Javascript?

My first instinct is to leave it as target=”_blank.” Even if that feature is not supported by browsers in the future, it should just be ignored and it should break gracefully. However, if JavaScript gets changed in the future, it could break in a way that throws errors to the user. Your thoughts? Am I overlooking a third and better alternative?
posted by Tallguy to Computers & Internet (12 answers total)
 
It sounds as though the editor's goals (popup windows) conflict with your goals (longevity). Find out from whoever is in charge of the project which is more important; if it's the longevity, I'd suggest that you forgo the browser tricks. Popup windows will seem quaint and sad -- and possibly broken -- in ten years in any case; they already are today.

target="_blank" is so widely used today that I suspect it will be the last to break, though, so if you have to bite the bullet and deploy with popups despite your better judgement, I suggest using that.
posted by majick at 6:45 AM on June 14, 2005


I'm going to agree with majick here. I'd be surprised if either were broken in the near future; there's just too much intertia on the web. JS is finally starting to become widely-used, and breaking such a (IMHO) central piece of it as window.open() would be a big step that would only slowly (if ever) be completely adopted. Same for target="_blank". Standards are standards, but it'll be a long, long, long time until browsers stop recognizing it.
posted by Plutor at 6:52 AM on June 14, 2005


This statement

XHTML Strict 1.0 ... but that is not an issue with the subset of tags I am using on this project, so not a problem.

and this statement

XHTML Strict does away with the target="_blank" tag for anchors

seem to be in conflict. If you need target="_blank" and are concerned about w3c compliance, use XHTML Transitional.

As for real world longevity, I wouldn't worry too much about the Javascript solution breaking, assuming (the link is broken) you're using the script that iterates over every anchor in the DOM and adds a target="_blank". If this script fails, the links are still left as they are on the page, and future user will be able to follow them without problem.
posted by alan at 7:12 AM on June 14, 2005


And popup windows are just plain irritating. If I want a popup window, I'll use my browser to open one myself, thankyouverymuch.
posted by grouse at 7:30 AM on June 14, 2005


Use a Javascript method like:
function go(url) {
onclick:popup=window.open(url,"name","");
}

and then call it in the HTML with:
<a href="page.html" onclick="go(this.href);return false;">

This creates a functioning Javascript pop-up — but if the Javascript should fail (or if the user tries to open the link in a new window or tab manually) the link will remain functional (and is still spidered by search engines).
posted by rafter at 7:38 AM on June 14, 2005


Avoid the JavaScript except as a fall-back: people are likely to turn off JavaScript now, much less 10 years from now.
posted by orthogonality at 8:35 AM on June 14, 2005


Or use Jeremy Keith's DOM solution as presented at the superb @media2005 in London last week. No JS event handlers in the code, rather an excellent DOM solution that will work if JS is disabled/unavailable.
posted by TheDonF at 8:38 AM on June 14, 2005


Alan:

Just to be clear, what I meant is that all of the tags I am using work in the browser right now. I would like for them to work in the browser and be standards-compliant (to ensure future compatibility). My parenthetical comment was to indicate that I know that you can use some tags that are standards-compliant that will not display correctly in current browsers. That is not a problem for me.
posted by Tallguy at 10:23 AM on June 14, 2005


If I were to propose to my editor not to spawn a new window, what would you guys suggest? Many of the target="_blank" commands are used for large images, in the 2k x 2k pixel size range and sometimes larger. I am normally opposed to spawning new windows, but this seems like a reasonable, and commonly encountered, exception.
posted by Tallguy at 10:27 AM on June 14, 2005


A 2000px × 2000px image is huge! Has anyone thought about users' monitor resolutions? As far as accessibility is concerned, you shouldn't spawn new windows unless you specifically tell the user in the link that you're going to do so, eg: 'my huge picture [opens in new window]', for example.

Not having been an IE user for a few years now, I hate spawned windows - I just want the same window or, should I wish, right-click and open in new tab.
posted by TheDonF at 2:50 PM on June 14, 2005


Just use a normal link. Modern browsers give the user more than enough control in the form of fullscreening, image resizing, and scrolling that whatever advantages you gain from opening a new window are obliterated by the annoyance.
posted by breath at 4:08 PM on June 14, 2005


and the best standard right now is XHTML Strict 1.0.

It's a recommendation, not a standard. And it's not the only one (let alone the best) as others have pointed out.

But if you want to be, um, strict about it, I trust you will also follow the recommendation of serving it up with content type application/xhtml+xml, not text/html.
posted by Ayn Marx at 5:58 PM on June 30, 2005


« Older Upcoming.org to Outlook to Palm?   |   Wireless Internet in Ottawa Newer »
This thread is closed to new comments.