Created
October 23, 2012 12:08
-
-
Save shergin/3938422 to your computer and use it in GitHub Desktop.
javascript protocol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="#" onclick="return onLinkClick(this)" link="http://softline.ru">SoftLine</a> | |
window.addEventListener('onload', onLoad, false); | |
function onLoad() { | |
var nodes = document.getElementsByTagName('a'); | |
for (var i = nodes.length; i--;) { | |
var node = nodes[i]; | |
var link = node.getAttribute('link'); | |
if (link) { | |
node.setAttribute('href', link); | |
node.removeAttribute('onclick'); | |
} | |
} | |
} | |
function onLinkClick(node) { | |
var link = node.getAttribute("link"); | |
if (link) { | |
node.setAttribute("href", link); | |
node.removeAttribute('onclick'); | |
window.location.href = link; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment