Sadie LaBounty
Sadie LaBounty

Reputation: 379

Attach Link to Entire HTML5 Canvas

I am trying to attach a link to an HTML canvas, such that it is loaded on clicking anywhere in the canvas.

It seems like this should be a very simple problem, but I couldn't get it to work with an <a> tag. The only way I can think of doing it is to attach an event listener to the canvas in Javascript and then attach the link from there - however, I would rather a pure HTML solution if possible.

Upvotes: 0

Views: 39

Answers (1)

A.Ishtiaq
A.Ishtiaq

Reputation: 36

Using <a> tag works for me.

<a href="http://www.google.com">
    <canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">
    </canvas>
</a>

Upvotes: 2

Related Questions