I encountered a problem where I needed to get the length and width of an image. It works fine under IE and FireFox, but it doesn't work in Chrome. Someone on the Internet said it can, and then it comes down to whether it is a problem with the Chrome version.
Finally, I found the answer.
In most cases, put the js code behind the image tag: