Created
March 19, 2020 07:55
-
-
Save mattocchi/96df27ccc24fe48b46decd0618e0d349 to your computer and use it in GitHub Desktop.
leggere dimensioni originali immagine da javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>JavaScript Find Real Image Width and Height</title> | |
| <script> | |
| function imgSize() { | |
| var myImg = document.querySelector("#sky"); | |
| var realWidth = myImg.naturalWidth; | |
| var realHeight = myImg.naturalHeight; | |
| alert("Original width=" + realWidth + ", " + "Original height=" + realHeight); | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <img src="https://test.aleven.it/KatiaServer/images/generic/katiaserver-trasp.png" id="sky" width="250" alt="Cloudy Sky"> | |
| <p><button type="button" onclick="imgSize();">Get Original Image Size</button></p> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment