JS interesse |
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script>
// Attach Click events to images, Barry de Rond
function NavigateToImage(url) {
if(url) {
document.location.href=url;
} else {
throw new Error("Image URL undefined");
}
}
function AddClickEventToImages() {
var imageList = document.getElementsByTagName("img");
for(var i = 0; i < imageList.length; i++) {
imageList[i].style.cursor="pointer";
addEvent(imageList[i], "click", function(event){
if(document.all) {
NavigateToImage(event.srcElement.src);
} else {
NavigateToImage(event.currentTarget.src);
}
});
}
}
function addEvent(obj, evType, fn) {
if (obj.addEventListener){
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
function removeEvent(obj, evType, fn) {
if (obj.removeEventListener){
obj.removeEventListener(evType, fn, false);
return true;
} else if (obj.detachEvent){
var r = obj.detachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
window.onload = function() {
AddClickEventToImages();
}
</script>
</head>
<body>
<img src="Social_Twitter.png" alt="" />
<img src="Social_RSS.png" alt="" />
<img src="Social_Stumble.png" alt="" />
<img src="Social_Technorati.png" alt="" />
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> // Attach Click events to images, Barry de Rond function NavigateToImage(url) { if(url) { document.location.href=url; } else { throw new Error("Image URL undefined"); } } function AddClickEventToImages() { var imageList = document.getElementsByTagName("img"); for(var i = 0; i < imageList.length; i++) { imageList[i].style.cursor="pointer"; addEvent(imageList[i], "click", function(event){ if(document.all) { NavigateToImage(event.srcElement.src); } else { NavigateToImage(event.currentTarget.src); } }); } } function addEvent(obj, evType, fn) { if (obj.addEventListener){ obj.addEventListener(evType, fn, false); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } function removeEvent(obj, evType, fn) { if (obj.removeEventListener){ obj.removeEventListener(evType, fn, false); return true; } else if (obj.detachEvent){ var r = obj.detachEvent("on"+evType, fn); return r; } else { return false; } } window.onload = function() { AddClickEventToImages(); } <img src="Social_Twitter.png" alt="" /> <img src="Social_RSS.png" alt="" /> <img src="Social_Stumble.png" alt="" /> <img src="Social_Technorati.png" alt="" />
Aangepast: vrijdag 7 Aug, 10:00 uur |