FF1+ IE5+ Opr7+

Open offsite links in new window

Author: Dynamic Drive

Note: Script rewritten Aug 28th 07'

Description: Concerned about people leaving your site when navigating to offsite links? This script lets you either automatically have all offsite links open in a new window, or let the user decide, via a checkbox. Links that belong to your own domain(s)- as specified by you inside the script- are not affected either way. A quick rundown of this script:

  • Two modes of operation- "auto" or "manual". In the former, all links on the page that do not match a list of excluded domains will open in a new window. In the later, a checkbox is displayed letting the user decide how these offsite links should open.
  • In "manual" mode, cookies are used to remember the user's checkbox setting for 30 days.

Demo: ("manual" mode shown):

Try clicking on links on this page that do not contain the "dynamicdrive.com" root. Here's some:

Ask.com | JavaScript Kit | News.com | CSSDrive | CodingForums | Dynamic Drive CSS (<-- unaffected by script)


Directions: Developer's View

Simply add the following script to the <BODY> section of your page where you wish the "checkbox" interface to appear (applicable if you're using "manual" mode):

Select All

The script above references an external .js file, which you need to download:

That's it!

Wordpress Users: Step by Step instructions to add ANY Dynamic Drive script to an entire Wordpress theme or individual Post