JSFiddle - React, Tailwind, and code Playground
by Graham Fairweather
HTML
<a href="http://img145.imageshack.us/img145/1750/barcelonaagbartowernighnx7.jpg">One</a>
<a href="http://img515.imageshack.us/img515/5390/005cc0.jpg">Two</a>
<a href="http://imageshack.us/a/img708/9470/compatiblechrome.gif">Three</a>
JavaScript
(function () {
window.addEventListener("load", function onLoad() {
this.removeEventListener("load", onLoad);
Array.prototype.forEach.call(document.getElementsByTagName("a"), function (anchor) {
anchor.addEventListener("click", function (evt) {
evt.preventDefault();
var newImg = document.createElement("img");
newImg.src = anchor.href;
newImg.addEventListener("load", function imgLoad() {
this.removeEventListener("load", imgLoad);
window.open(newImg.src, "image", "width=" + newImg.width + "px,height=" + newImg.height + "px");
}, false);
}, false);
});
}, false);
}());