我有以下带有 javascript 的 Html 文件。这给了我“testCircle 未定义”的错误。kinldy 帮我解决这个问题。
<html>
<body>
<h1> Testing Object-based Javascipt </h1>
<script type="text/javascript">
function mycircle(x,y,r)
{
this.xcoord=x;
this.ycoord=y;
this.radius=r;
this.area = getArea;
this.getCircumference = function () { return (2 * Math.PI * this.radius ) ; };
}
function getArea()
{
return (Math.PI * this.radius * this.radius);
}
var testCircle = mycircle(3,4,5);
window.alert('The radius of my circle is ' + testCircle.radius);
</script>
</body>
</html>
提前致谢....