Henry
Henry

Reputation: 1337

How to add URL to an image in Fabric.js?

Using object.on('selected', function() {}), I can get the image object that is clicked. My intent is to redirect to an URL by clicking it. How can I add an URL to an image, or more general, to an object in Fabric.js?

Upvotes: 1

Views: 1939

Answers (1)

AlliterativeAlice
AlliterativeAlice

Reputation: 12587

You can simply navigate to the target page in the selected event handler:

object.on('selected', function() {
    window.location.href = "http://www.example.com/";
})

Upvotes: 2

Related Questions