简体   繁体   中英

Add link in a video or a gif

Do you know any solution to click an element in an animated media, eg gif or video?

Example in the attached link how I can open a link when I click (at any time) on the running guy. link

You can do it with javascript by putting a click function on the containing element:

 document.getElementById("media-holder").onclick = function () { location.href = "https://google.com"; };
 #media-holder { cursor:pointer; }
 <div id="media-holder"> <img src="https://i.giphy.com/media/l2Sqc3POpzkj5r8SQ/giphy.webp" /> </div>

Or you can wrap the element in an anchor tag:

 <a href="https://google.com"> <img src="https://i.giphy.com/media/l2Sqc3POpzkj5r8SQ/giphy.webp" /> </a>

I solved my problem with the Freezeframe.js library.

Demo: https://ctrl-freaks.github.io/freezeframe.js/ Github: https://github.com/ctrl-freaks/freezeframe.js/

At the hover event the gif stops and there are links with a static position on each clickable element.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM