Join the Mozilla’s Test Days event from 9–15 Jan to test the new Firefox address bar on Firefox Beta 135 and get a chance to win Mozilla swag vouchers! 🎁

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

ఇంకా తెలుసుకోండి

How do I get naturalWidth / naturalHeight?

  • 1 ప్రత్యుత్తరం
  • 1 ఈ సమస్య కలిగినది
  • 49 వీక్షణలు
  • చివరి సమాధానమిచ్చినది vrcode

more options

I believe there is a bug. I can't get naturalWidth / naturalHeight in Firefox. Neither Safari nor Chrome has this problem.

JavaScript code:

let image = document.querySelector("img"); console.log("natural width=" + image.naturalWidth + ", " + "natural height=" + image.height);

The code printed a value of 0 in Firefox whereas browsers printed the respective width and height of the image.

I believe there is a bug. I can't get naturalWidth / naturalHeight in Firefox. Neither Safari nor Chrome has this problem. JavaScript code: let image = document.querySelector("img"); console.log("natural width=" + image.naturalWidth + ", " + "natural height=" + image.height); The code printed a value of 0 in Firefox whereas browsers printed the respective width and height of the image.
జోడించిన స్క్రీన్షాట్లు

ఎంపిక చేసిన పరిష్కారం

Edit:

solution/workaround: wait for everything to completely load by putting code in


       window.addEventListener('load', function() {
       //code
       });
ఈ సందర్భంలో ఈ సమాధానం చదవండి 👍 0

ప్రత్యుత్తరాలన్నీ (1)

more options

ఎంపిక చేసిన పరిష్కారం

Edit:

solution/workaround: wait for everything to completely load by putting code in


       window.addEventListener('load', function() {
       //code
       });

న vrcode చే మార్చబడినది