0

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.

waiwai933
  • 14,133
  • 21
  • 62
  • 86

3 Answers3

0

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
  • 3,375
  • 1
  • 22
  • 27
  • 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 Apr 01 '10 at 01:01
0

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 :)

Thiago Belem
  • 7,732
  • 5
  • 43
  • 64
0

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
  • 111
  • 1
  • 8