This script is a valid way for customize the opening of a external link.
The visitor can choose if open external links in a new browser window or in the same browser window.
The script consists of two parts: the first one within the <head> section, and the other one within the <body> section.
This script is compatible with Explorer, Netscape 6, Mozilla, Safari, Opera.
Part one within the
<head> section of your page:
<script language="JavaScript" type="text/JavaScript">
<!--
var mioSito="http://www.parlandosparlando.com";
function wo(_checked)
{
where = _checked?"_blank":"_self";
for (var i=0; i<=(document.links.length-1); i++)
{
if(document.links[i].href.indexOf(mioSito)<0)
document.links[i].target=where;
}
}
// -->
</script>
Part two within the
<body> section of your page (where you want the message to be displayed)
(The message text must be clearly):
<form name="form">
<input type="checkbox" name="checktarget" onclick="wo(this.checked)">
Open outside links in a new window.
</form>
Here is the url to the script in .txt file
Analysis of the script
The
mioSito variable contains your web site's domain name.
The
wo(_checked) function inspects all links in the page, checking the
href attribute. If this
function finds your web site's domain name stored (or a relative URL) into the
mioSito variable, the
link will have opened in the same browser window.
But if it is a external link, the checkbox is inspected. If the checkbox is checked will be opened in a new
window (target="_blank") also it will be opened in the same window (target="_self").