Windows 10 will reach EOS (end of support) on October 14, 2025. For more information, see this article.

Avatar for Username

ძიება მხარდაჭერაში

ნუ გაებმებით თაღლითების მახეში. აქ არავინ უნდა მოგთხოვოთ ტელეფონზე დარეკვა, შეტყობინების გაგზავნა ან პირადი მონაცემების გაზიარება. რამე საეჭვოს შემჩნევისას გთხოვთ გვაცნობოთ „დარღვევის მოხსენებით“.

ვრცლად

How do I get naturalWidth / naturalHeight?

  • 1 პასუხი
  • 1 მომხმარებელი წააწყდა მსგავს სიძნელეს
  • 44 ნახვა
  • ბოლოს გამოეხმაურა vrcode

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)

შერჩეული გადაწყვეტა

Edit:

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


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

ჩასწორების თარიღი: , ავტორი: vrcode