Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 加载后检查图像的大小_Javascript_Html - Fatal编程技术网

Javascript 加载后检查图像的大小

Javascript 加载后检查图像的大小,javascript,html,Javascript,Html,我有一个图像地图,我希望在地图调整大小时替换坐标(例如,如果客户端更改窗口大小) 到目前为止,使用Javascript我已经能够在加载时保存图像的大小,但我还没有弄清楚如何使其在加载页面后被动地检查图像的大小。 这是HTML: <!DOCTYPE html> <html> <title> Image Resize </title> <head> <script src= "/Jquery/Jquery.js&qu

我有一个图像地图,我希望在地图调整大小时替换坐标(例如,如果客户端更改窗口大小) 到目前为止,使用Javascript我已经能够在加载时保存图像的大小,但我还没有弄清楚如何使其在加载页面后被动地检查图像的大小。 这是HTML:

<!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);
          }
     }
});