You can't add event listeners to a context, only to the canvas:
document.getElementById('canvasOff1').addEventLsitener(
'click',
function(){ goToUrl('http://www.test1.com'); }
);
document.getElementById('canvasReal').addEventLsitener(
'click',
function(){ goToUrl('http://www.test2.com'); }
);
document.getElementById('canvasOff3').addEventLsitener(
'click',
function(){ goToUrl('http://www.test3.com'); }
);
function goToUrl(url){
window.location = url;
}
Or, with jQuery:
$('#canvasOff1').on(
'click',
function(){ goToUrl('http://www.test1.com'); }
);
$('#canvasReal').on(
'click',
function(){ goToUrl('http://www.test2.com'); }
);
$('#canvasOff3').on(
'click',
function(){ goToUrl('http://www.test3.com'); }
);
function goToUrl(url){
window.location = url;
}
(I prefer using a separate function for window.location = X
, but of course, you couls also use it in the onclick
function, like this:
function(){ window.location = 'http://www.test1.com'; }