I have a simple JS script that moves a CSS block at a specific path when a value is given to it.
You can take a look at the code here http://jsfiddle.net/rayshinn/6DGfb/
This code seem to work fine on Chrome and Firefox except IE7.
The error I get from IE is as follows
Line: 27
Char:13
Error: Object doesn't support this property or method
Code: 0
URL: http://localhost/test/js/plot.js
Line 27 is as follows
marker = document.getElementById("marker");
this.setPosition(INITIAL_X, INITIAL_Y);
Below is my full JS script for your reference.
(function () {
var INITIAL_X = 550,
INITIAL_Y = 152;
// f(v) -> {"x" : x, "y" : y}
var calculatePosition = function (value) {
var result = {};
result.x = INITIAL_X - value / 9;
result.y = INITIAL_Y + 0.117 * value/ 9 ;
return result;
}
var map = {
marker : null,
value : 0,
setPosition : function (x, y) {
marker.style.left = x + "px";
marker.style.top = y + "px";
},
init : function () {
marker = document.getElementById("marker");
this.setPosition(INITIAL_X, INITIAL_Y);
},
increment : function () {
this.value++;
var result = calculatePosition(this.value);
this.setPosition(result.x, result.y);
},
decrement : function() {
this.value--;
var result = calculatePosition(this.value);
this.setPosition(result.x, result.y);
}
};
map.init();
for (var i = 0; i < 100; i++) {
map.increment();
}
})();
Thank you for taking your time to read this and helping me solve this issue.
As always any suggestions will be greatly appreciated!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…