How do I get naturalWidth / naturalHeight?
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 เมื่อ