Wednesday, March 20, 2013

Hacking the HTML a tag in 100 characters

http://bilaw.al/2013/03/17/hacking-the-a-tag-in-100-characters.html
// Uncompressed
var links = document.links;
for(i in links) {
    links[i].onclick = function(){
        this.href = 'http://bit.ly/141nisR';
    };
}

// Compressed (was 100; now 67 characters exc. the link)
// Thanks to sgoel from HN
o=document.links;for(i in o){o[i].onclick=function(){this.href='//bit.ly/141nisR'}}

No comments:

Post a Comment