Last active
August 29, 2015 14:25
-
-
Save webbower/a0c70bf3afa61754a704 to your computer and use it in GitHub Desktop.
Allow JS links to respect opening in new window or now
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
someElement.addEventListener('click', function(ev) { | |
var url = someElement.get('data-url'); | |
if(e.metaKey || e.ctrlKey) window.open(url); | |
else window.location = url; | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment