我正在从 html 调用 javascript 函数。但它一直返回错误并说函数未在jsfiddle中定义。
这是html代码
<div id="Container">
<img alt="Click to zoom" class="image" onclick="resizeImg(this)"
src="http://www.extremetech.com/wp-content/uploads/2012/12/Audi-A1.jpg" />
</div>
这是javascript
function resizeImg (img) {
var resize = 150; // resize amount in percentage
var origH = 61; // original image height
var origW = 250; // original image width
var mouseX = event.x;
var mouseY = event.y;
var newH = origH * (resize / 100);
var newW = origW * (resize / 100);
// Set the new width and height
img.style.height = newH;
img.style.width = newW;
var c = img.parentNode;
// Work out the new center
c.scrollLeft = (mouseX * (resize / 100)) - (newW / 2) / 2;
c.scrollTop = (mouseY * (resize / 100)) - (newH / 2) / 2;
}
为什么以及如何解决它?