2 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
3 * Copyright (C) 2002-2005 The Nucleus Group
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
9 * (see nucleus/documentation/index.html#license for more info)
\r
11 * $Id: opennew.js,v 1.3 2005-03-12 06:19:04 kimitake Exp $
\r
14 * JavaScript to open non-local links in a new window.
\r
17 * in the <head>...</head> section of your page, add the following line:
\r
19 * <script type="text/javascript" src="nucleus/javascript/opennew.js"></script>
\r
21 * Then, add the following to your <body> tag:
\r
23 * <body ... onload="setOpenNewWindow(true);">
\r
25 * And you're all done.
\r
27 * Variables that can be overridden if necessary:
\r
28 * local = something to recognize local URLs (by default, if your page is something like
\r
29 * http://www.example.com/path/page.html, then local will be automatically set to
\r
30 * http://www.example.com/path/)
\r
31 * exception = something to recognize exceptions to the local check. You might need this
\r
32 * when you use a 'click-through' type of script (e.g. when
\r
33 * http://www.example.com/path/click.php?http://otherpage.com/ would
\r
34 * auto-redirect to otherpage.com and record a click in your logs)
\r
35 * In most of the cases, this variable is unneeded and can be left empty
\r
36 * destinationFrame = name of the destination frame (by default this is "_blank" to spawn a
\r
37 * new window for each link clicked)
\r
41 var local = document.URL.substring(0,document.URL.lastIndexOf('/'));
\r
43 var destinationFrame = "_blank";
\r
45 function setOpenNewWindow(newWin) {
\r
47 from = ""; to = destinationFrame;
\r
49 from = destinationFrame; to = "";
\r
52 for (var i=0; i<=(document.links.length-1); i++) {
\r
53 if (document.links[i].target == from) {
\r
55 var href = document.links[i].href;
\r
56 var isLocal = (href.indexOf(local) != -1);
\r
57 if (isLocal && ((exception=="") || (href.indexOf(exception) != -1)))
\r
60 document.links[i].target = to;
\r