у меня есть изображение является настройка на OnLoad событий:проблемы с получением элемента
function hideMe() {
document.getElementById("navy1").style.display = "none";
}
и у меня есть еще одна функция, что установка изображения на экране:
function setUpPicture() {
subRunnerOBJ = new Object();
subRunnerOBJ.topPos = 100;
subRunnerOBJ.leftPos = 0;
subRunnerOBJ.velX = 400;
subRunnerOBJ.velY = 0;
subRunnerOBJ.score = 0;
snImgObj = document.getElementById("navy1");
// в этом пункте я получаю сообщение «Ошибка выполнения Microsoft JScript: невозможно получить значение свойства« style »: объект имеет значение null или undefined»
snImgObj.style.left = subRunnerOBJ.leftPos + "px";
snImgObj.style.top = subRunnerOBJ.topPos + "px";
snImgObj.style.position = "absolute";
snImgObj.style.display = "show";
startMovePicture();
любая идея, почему это случилось?
//this one will set the the pictue on the right side of the screen
function setUpPicture() {
subRunnerOBJ = new Object();
subRunnerOBJ.topPos = 100;
subRunnerOBJ.leftPos = 0;
subRunnerOBJ.velX = 400;
subRunnerOBJ.velY = 0;
subRunnerOBJ.score = 0;
//document.getElementById("navy1").style.display = "show";
snImgObj = document.getElementById("navy1");
snImgObj.style.left = subRunnerOBJ.leftPos + "px";
snImgObj.style.top = subRunnerOBJ.topPos + "px";
snImgObj.style.position = "absolute";
snImgObj.style.display = "show";
//once we place the location of the sub , we will Call to new function that will move it
startMovePicture();
}
function startMovePicture() {
dt = 50; // in miliseconds
h = setInterval("moveObj(subRunnerOBJ)", dt);
}
function moveObj(someObj) {
counter = 0;
while (counter < 3000) {
subRunnerOBJ.leftPos = subRunnerOBJ.leftPos + subRunnerOBJ.velX * dt/1000;
subRunnerOBJ.topPos = subRunnerOBJ.topPos + subRunnerOBJ.velY * dt/1000;
snImgObj.style.left = subRunnerOBJ.leftPos + "px";
snImgObj.style.top = subRunnerOBJ.topPos + "px";
counter = counter + 50;
if (counter == 3000) {
stopRunning()
}
}
}
function stopRunning() {
clearInterval(h);
hideMe();
}
//this function will hide the pucture on liad , and once the loop with the Pictue Running will end
//once loading the page we will not see the Picture
function hideMe() {
document.getElementById("navy1").style.display = "none";
}
}
это [тег: Java] или [тег: JavaScript]? – secretformula
Покажите нам полный код, что-то здесь невозможно. – gdoron
Проверить полный код –