Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Javascript Cloak and redirect link CODE
#1
Code:
<body>

<a href='http://google.com/' name='http://yahoo.com'>Visit
yahoo.com</a>


</body>


<script language="javascript">
_links = document.getElementsByTagName("a");
for(i=0;i<_links.length;i++) {
   if(_links[i].name) {
       docloak = function() {
           _cloak = this.href;
           this.href = this.name;
           this.innerHTML = _cloak;
       };        
       _links[i].oncontextmenu = docloak;                
       _links[i].onclick = function() {
           docloak();
           window.location = this.name;
           return false;
       };                        
       _tmp = _links[i].href;
       _links[i].href = _links[i].name;
       _links[i].name = _tmp;
   }
}
</script>
How it works: Make a link as usual. Add the “name=” attribute and set it
 to whatever you want displayed in the status bar. The javascript code 
at the bottom of the file does the rest. Make sure you put the 
javascript code AFTER all of the links on the page. When the user hovers
 over the link, he will see whatever you set in the name attribute. As 
you can see, this technique allows you to control exactly what gets 
displayed in the status bar. If javascript is disabled, the user will 
see the real destination url, but that’s about the only downside.
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)