Using the Target Attribute | JavaScriptSource

Using the Target Attribute

Alan Coleman Jun 11, 2007


At times you may need to launch certain links into a new window. The 'target' attribute is deprecated and is therefore not allowed when using XHTML with a strict doctype. Using this script, you will be able to keep your pages valid while also using the target attribute to open new windows.


Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: targetAttribute.js


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document

Leave a Response

(1 comment)

If the target attribute is appreciated in XHTML, than it is not in the dom, and not valid XHTML. Wouldn't this cause an error at some point, on some browser?

Shulem Jeremias Jun 15, 2007