Page is a not externally linkable
- WebmasterWorld
-- Accessibility and Usability
---- Accesibility and Pop-ups


jalarie - 9:41 pm on Aug 14, 2011 (gmt 0)


I am using JavaScript to alert the user to the fact that something unexpected is happening and allow the choice to block it. If scripting is not enabled, the link opens in the same window. The links look like this; note the "onclick..." item:

<a href="http://www.mozilla.org/" onclick="return OffSite(this);" title="Mozilla">mozilla.org</a>

The code to handle it also does forms and and "onclick" buttons:

function OffSite(What) {
// <a href="http://..." onclick="return OffSite(this);">...</a>
// <form ... onsubmit="return OffSite(this);...">
// button onclick="OffSite(this);..."
var OS_href, OS_action, OS_onclick, OS_Message, OS_Confirm;
OS_href=What['href'];
OS_action=What['action'];
OS_onclick=What['onclick'];
if ((OS_href)
&& (OS_href != '')
&& (OS_href != 'undefined')) { // an "a" tag
if (OS_href.substring(0,4) == 'http') { // only the non-404's
What.target='_blank';
OS_Message ='';
OS_Message+='You are now leaving my site; thank you for ';
OS_Message+='visiting. The target site may open in ';
OS_Message+='a new window; please close it when you wish ';
OS_Message+='to return. ';
OS_Confirm=confirm(OS_Message);
return OS_Confirm;
}
return true;
} // end of "a" tag
if ((OS_action)
&& (OS_action != '')
&& (OS_action != 'undefined')) { // a "form" tag
What.target='_blank';
OS_Message ='';
OS_Message+='This form links to a program outside of my ';
OS_Message+='site. It may open it\'s results in a new ';
OS_Message+='window; please close it when you wish to ';
OS_Message+='return. ';
OS_Confirm=confirm(OS_Message);
return OS_Confirm;
} // end of "form" tag
if ((OS_onclick)
&& (OS_onclick != '')
&& (OS_onclick != 'undefined')) { // an "onclick" button
OS_Message ='';
OS_Message+='This button links to a program outside of my ';
OS_Message+='site. It may open in a new window; please ';
OS_Message+='close it when you wish to return. ';
OS_Confirm=confirm(OS_Message);
return OS_Confirm;
} // end of "onclick" button
return true;
} // OffSite


Thread source:: http://www.webmasterworld.com/accessibility_usability/4278891.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com