| [ Index ] |
PHP Cross Reference of Nucleus CMS 3.32 |
[Summary view] [Print] [Text view]
1 /* 2 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 3 * Copyright (C) 2002-2007 The Nucleus Group 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * (see nucleus/documentation/index.html#license for more info) 10 * 11 * $Id: opennew.js 1116 2007-02-03 08:24:29Z kimitake $ 12 * 13 * JavaScript to open non-local links in a new window. 14 * 15 * How to use: 16 * in the <head>...</head> section of your page, add the following line: 17 * 18 * <script type="text/javascript" src="nucleus/javascript/opennew.js"></script> 19 * 20 * Then, add the following to your <body> tag: 21 * 22 * <body ... onload="setOpenNewWindow(true);"> 23 * 24 * And you're all done. 25 * 26 * Variables that can be overridden if necessary: 27 * local = something to recognize local URLs (by default, if your page is something like 28 * http://www.example.com/path/page.html, then local will be automatically set to 29 * http://www.example.com/path/) 30 * exception = something to recognize exceptions to the local check. You might need this 31 * when you use a 'click-through' type of script (e.g. when 32 * http://www.example.com/path/click.php?http://otherpage.com/ would 33 * auto-redirect to otherpage.com and record a click in your logs) 34 * In most of the cases, this variable is unneeded and can be left empty 35 * destinationFrame = name of the destination frame (by default this is "_blank" to spawn a 36 * new window for each link clicked) 37 */ 38 39 40 var local = document.URL.substring(0,document.URL.lastIndexOf('/')); 41 var exception = ""; 42 var destinationFrame = "_blank"; 43 44 function setOpenNewWindow(newWin) { 45 if (newWin) { 46 from = ""; to = destinationFrame; 47 } else { 48 from = destinationFrame; to = ""; 49 } 50 51 for (var i=0; i<=(document.links.length-1); i++) { 52 if (document.links[i].target == from) { 53 54 var href = document.links[i].href; 55 var isLocal = (href.indexOf(local) != -1); 56 if (isLocal && ((exception=="") || (href.indexOf(exception) != -1))) 57 isLocal = false; 58 if (!isLocal) 59 document.links[i].target = to; 60 } 61 } 62 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Feb 12 15:34:36 2008 | Cross-referenced by PHPXref 0.7 |