Created
December 2, 2013 07:19
-
-
Save intruxxer/7746186 to your computer and use it in GitHub Desktop.
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
sethrefs = function () { | |
if (document.querySelectorAll) { | |
var datahrefs = document.querySelectorAll('[data-href]'), | |
dhcount = datahrefs.length; | |
while (dhcount-- > 0) { | |
var ele = datahrefs[dhcount], | |
link = function (event) { | |
var target = event.target; | |
if (!event.target.href) window.location.href = this.getAttribute('data-href'); | |
}; | |
if(ele.addEventListener) ele.addEventListener('click', link, false); | |
else ele.attachEvent('onclick', link); | |
} | |
} | |
}; | |
sethrefs(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment