Click here to Skip to main content
16,021,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I have a video on a website, I want to detect a mouse click in a specific place on the video for example in the centre of a video. The point is that in the video content a button appears and when a user clicks on it I want it to be redirected to the url page.
For now I have something like this.
JavaScript
 <video id="current_video" class="video-js" width="400" height="300" controls="controls" preload="auto">
   <source src="video.mp4" type='video/mp4' />  
    

 $('body').on('click', function(e) {

   
    if (e.pageX <= 500 && e.pageY <= 500) {

    
       alert("cool");
    }
});
  </video>


Now I have the 500x500 pixels covered, but I want to find the specific spot inside the video. I know I could find the spot according to the whole webpage pixels, but I want this to work in all browsers. Any solution to solve this would bring me joy. Thank You.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900