»
EnglishFrenchVietnamese

Print - Link Enhancer - JavaScriptBank.com

Full version: jsB@nk » Link » Link Enhancer
URL: https://www.javascriptbank.com/link-enhancer-index.html

Link Enhancer © JavaScriptBank.comUsing this script, outbound links will open in a new window automatically. No need to add anything to the link. The script will also apply a different style to the outbound link to make visitors aware it is an outbound link. You don't have to worry anymore about targets and the appearance, especially if your customers have their own CMS.

Full version: jsB@nk » Link » Link Enhancer
URL: https://www.javascriptbank.com/link-enhancer-index.html



CSS
<style type="text/css">.link_ext { height: 20px; background: url(link_ext.gif) no-repeat right 4px; padding: 0 13px 0 0;}</style><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<script type="text/javascript">/* -----------------------------------------------   Link Enhancer - v.1.1   (c) 2007 www.haan.net   contact: [email protected]   You may use this script but please leave the credits on top intact.   Please inform us of any improvements made.   When useful we will add your credits.  ------------------------------------------------ */  // Give the outbound links a blank target and their own style// and optional the inbound too or vise versa// It will leave the mailto alone and skip anchor tags without the href attributefunction enhanceLinks() { var links = document.getElementsByTagName("a"); var thisDomain = document.domain.split('www.'); var thisDomain = (thisDomain[1]) ? thisDomain[1] : document.domain ; for (var i = 0; i < links.length; i++) {  if(links[i].href.indexOf(thisDomain) == -1 && links[i].href != '') {   links[i].target = '_blank';   links[i].className = 'link_ext';  }// or else do this too if you like// else // {//links[i].target = '_self';//links[i].className = 'link_int';// }}}// Multiple onload function created by: Simon Willison// http://simon.incutio.com/archive/2004/05/26/addLoadEventfunction addLoadEvent(func) {  var oldonload = window.onload;  if (typeof window.onload != 'function') {    window.onload = func;  } else {    window.onload = function() {      if (oldonload) {        oldonload();      }      func();    }  }}addLoadEvent(function() {  enhanceLinks();});</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<ul>  <li><a href="http://www.javascriptbank.com/">Web Developer</a></li>  <li><a href="http://javascriptbank.com/">JavaScript Source</a></li></ul><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


Files
http://javascriptbank.com/javascript/link/Link_Enhancer/link_ext.gif