function Point(x, y, color)
{
this.xLabel = x;
this.yLabel = y;
this.color = color;
this.DrawPoint() = function(x,y,color){
this.xLabel = x;
this.yLabel = y;
this.color = color;
document.write('<div style="position:absolute;top:'+ this.yLabel +'px;left:'+ this.xLabel +'px;width:1px;height:1px;background:' +this.color+';font-size:1px;visibility:visible"></div>');
return;
} var pt =new Point();
为什么会执行到this.DrawPoint() = function(x,y,color)里。这是个正常现象吗?
{
this.xLabel = x;
this.yLabel = y;
this.color = color;
this.DrawPoint() = function(x,y,color){
this.xLabel = x;
this.yLabel = y;
this.color = color;
document.write('<div style="position:absolute;top:'+ this.yLabel +'px;left:'+ this.xLabel +'px;width:1px;height:1px;background:' +this.color+';font-size:1px;visibility:visible"></div>');
return;
} var pt =new Point();
为什么会执行到this.DrawPoint() = function(x,y,color)里。这是个正常现象吗?
解决方案 »
- jquery中的ajax与火狐
- 解决此问题,另外赠送100分
- 请教:在javascript函数中是否能够写数据库操作语句?(没有分了 日后一定补上)
- 请问网页错误的403错误那些文件应该在哪里能找到
- fckeditor 怎么去掉里面的各个提示框中的上传标签
- TypeError: jsonObj[index] is undefined
- 怎么实现只在一个新窗口中打开链接?
- icyer 请进,各路绿林英雄来会会:C# 服务器脚本如何访问 JS 客户端脚本的变量值? 反过来行不行? JS 客户端脚本的变量值如何发给服务
- 有关object的text/x-scriptlet问题,在线
- 【求助】关于html2canvas的问题
- 根据产品名称自己刷新数量框后面的单位
- 请教JS显视问题
不过上面这个会报错,
this.DrawPoint() 加了括号等于是调用函数,而不是定义函数,但是这个函数貌似不存在
楼上的说法: this.DrawPoint() = function(x,y,color) 会运行我认为是有问题的,赋值语句的语法要求左边是一个变量,或是数组的一个元素,或是对象的一个属性,而this.DrawPoint()不符合任何条件,这句话语法就是错误的,所以不会运行,会出错
this.DrawPoint()就運行this.DrwaPoint函數你現在做的是定義對像和它的方法,this.DrawPoint都還沒定義(function...在後面),就被執行了(緊接的一對問題),第1個錯誤是不能給函數的結果(加上兩對括號得到的就是結果)賦值,第2個(隱含)的錯誤就是在那行之前都沒有this.DrawPoint(定義),哪能有this.DrawPoint()? 把緊接的兩個括號去掉就OK了。