Javascript 加载后检查图像的大小
我有一个图像地图,我希望在地图调整大小时替换坐标(例如,如果客户端更改窗口大小) 到目前为止,使用Javascript我已经能够在加载时保存图像的大小,但我还没有弄清楚如何使其在加载页面后被动地检查图像的大小。 这是HTML:Javascript 加载后检查图像的大小,javascript,html,Javascript,Html,我有一个图像地图,我希望在地图调整大小时替换坐标(例如,如果客户端更改窗口大小) 到目前为止,使用Javascript我已经能够在加载时保存图像的大小,但我还没有弄清楚如何使其在加载页面后被动地检查图像的大小。 这是HTML: <!DOCTYPE html> <html> <title> Image Resize </title> <head> <script src= "/Jquery/Jquery.js&qu
<!DOCTYPE html>
<html>
<title> Image Resize </title>
<head>
<script src= "/Jquery/Jquery.js"></script>
</head>
<body>
<img src = "/Images/image.png"
alt = "Image"
style = "width:75%;"
id ="image">
<br>
<p1> </p1>
<script src= "Javascript.js"></script>
</body>
</html>
我应该提到的是,我是通过Mac电脑上的文本编辑程序(而不是Node、Android Studio或其他IDE)编写的,并通过google chrome执行它。这一问题得到了解决。非常感谢。
var width = canvas.width;
var height = canvas.height
$("p1").text(width + ", "+ height);
$(document).ready(function(){
$function(){
if(image.width != width){
var width = canvas.width;
var height = canvas.height;
$("p1").text(width + ", "+ height);
}
}
});