Avatar for Username

Αναζήτηση στην υποστήριξη

Προσοχή στις απάτες! Δεν θα σας ζητήσουμε ποτέ να καλέσετε ή να στείλετε μήνυμα σε κάποιον αριθμό τηλεφώνου ή να μοιραστείτε προσωπικά δεδομένα. Αναφέρετε τυχόν ύποπτη δραστηριότητα μέσω της επιλογής «Αναφορά κατάχρησης».

Μάθετε περισσότερα

How do I get naturalWidth / naturalHeight?

  • 1 απάντηση
  • 1 έχει αυτό το πρόβλημα
  • 1 προβολή
  • Τελευταία απάντηση από 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