Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
Video dimensions dynamically

I have on my HTML page video player and player change dimensions depends on browser window side. So On start my video is 1280x720, and when I make my browser window smaller, my video is also smaller. I want to add button which will print to console current dimensions of video. I tried like this:

<button onclick="getDimensions()">getDimensions</button>

  <script>
      const myVideo = document.getElementById("video1");
      
      function getDimensions() {
        let height = myVideo.videoHeight;
        let width = myVideo.videoWidth;
        console.log(height, width);
      }
 </script>

but this code only print start dimensions 1280x720px. Does anyone have idea how to fix this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First you need to identify element:

element = document.getElementById('id');

and now get information about the size of an element and its position relative to the viewport.

domRect = element.getBoundingClientRect();

if i print it:

DOMRect {
    bottom: 177,
    height: 54.7,
    left: 278.5,​
    right: 909.5,
    top: 122.3,
    width: 631,
    x: 278.5,
    y: 122.3,
}

Documentation

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!