Opening New Windows | JavaScriptSource

Opening New Windows

Roger Johansson Dec 4, 2006

General

When using strict doctypes the target attribute is not allowed for opening new windows. This script will accomplish that task easily and unobtrusively.


Good JavaScript site!

Notes

The script uses the class name "non-html" so you will need to add that to the links you want to open in a new window, e.g., <a href="yourDocument.html" class="non-html">A sample file</a>

This script will not open a new window if a modifier key (ctrl/shift/etc.) is pressed while the link is clicked.

It also checks if the new window was successfully opened. If it was not, it returns true to allow the browser to open the link in the original window.

Source Code

Paste this source code into the designated areas.

External file

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


Head

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


Body

Paste this code into the BODY section of your HTML document


Leave a Response

(1 comment)

can these source code works for my frontpage created web

toba tunde Dec 5, 2006