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.

Learn More

Wannan tattunawa ta zama daɗaɗɗiya. Yi sabuwar tambaya idan ka na bukatar taimako.

How do I get naturalWidth / naturalHeight?

  • 1 amsa
  • 1 yana da wannan matsala
  • 1 view
  • Amsa ta ƙarshe daga 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.
Hoton allon fuska da aka liƙa

Mafitar da aka zaɓa

Edit:

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


       window.addEventListener('load', function() {
       //code
       });
Karanta wannan amsa a matsayinta 👍 0

All Replies (1)

more options

Zaɓi Mafita

Edit:

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


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

An gyara daga vrcode