Skip to content

Instantly share code, notes, and snippets.



Last active Jun 9, 2020
What would you like to do?
Enable each element to be linked
/* Copyright (c) 2016 Tobias Buschor | MIT License */
<tr data-c1-href="" data-c1-target="_blank">
<td> <a href="" target="_blank"></a>
<td> Do not forget to add a real link so that your content is accessible.
c1 = {
href: {
if (e.which !== 1) return;
if (e.defaultPrevented) return;
if (! return;
var A ='[data-c1-href]');
if (!A) return;
if ('a,input,textarea,select,button')) return;
if ('[fn], [onclick]')) return;
if ( return;
if ( return;
var href = A.getAttribute('data-c1-href');
if (!href) return;
var target = A.getAttribute('data-c1-target');
if (e.ctrlKey) target = '_blank'; // better random-string?
if (target) {, target);
//!e.ctrlKey && win.focus(); // not needed in chrome, not working in ff
} else {
location.href = href;
document.head.insertAdjacentHTML('beforeend','<style>[data-c1-href] {cursor:pointer},[data-c1-href=""]{cursor:normal}</style>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment