views:

23

answers:

3

Is there a way to open a page in XHTML without using <a href="page.html" target="_blank"> that is standards compliant?

I'm not using frames, but there are some pages that I want to open in a new window instead of the current one.

A: 

You can use javascript's window.open() method. However this could easily be blocked by a pop-up blocker. Why do you not want to use the "_blank" target?

Maz
It's not standards compliant with XHTML Strict. That won't stop me from using it, but if there's a method that is standards compliant, then it's probably better to use that.
waiwai933
A: 

You can use something like this:

<a href="page.html" rel="external">My Page</a>

And then you run this jQuery:

$(document).ready(function() {
    $('a[rel="external"]').attr('target', '_blank');
});

This will add the target="blank" to the links and make your HTML validate :)

TiuTalk
A: 

Most pop-up blockers wont block a pop up that has been requested by the user e.g you click a link and it pops up a window. IF you add an onlick event to your link and a target, the desired effect will work even if JS is turned off although you don't want to use target="_blank"

sidcom