/    Sign up×
Community /Pin to ProfileBookmark

setTimeout with getElementByID problems in IE

Hi

I’ve searched and couldn’t find anything helpful with my problem.

Please look at [URL=http://www.ctfarms.org/new/index.html]this animation[/URL] in both FF and IE.

It works well in FF, but flickers and sometimes the background does not appear in IE (unless you visit another page and use the back button)

I think the flicker issue has more to do with JS than CSS so I posted in this forum.

Can anyone shed some light on the issue for me?

Thanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@saulssOct 19.2005 — ...sorry for this post, please remove
Copy linkTweet thisAlerts:
@saulssOct 19.2005 — every time u are running the animate() function, in ur case every 0.025 of a second u are trying to modify
[CODE] document.getElementById('nos').style.backgroundImage = 'url("graphics/nos.gif")';
document.getElementById('nos').style.backgroundRepeat = 'repeat-y';
document.getElementById('nos').style.backgroundPosition = '50% '+m+'px';[/CODE]

(lots of memory being wasted)

u dont really need to modyfy the url of fhe image and the background repeat property do u?

well i u separate it in two parts so that one executes only once like this...
[CODE]
...
m=0;
function getReady()
{
document.getElementById('nos').style.backgroundImage = 'url("graphics/nos.gif")';
document.getElementById('nos').style.backgroundRepeat = 'repeat-y';
}
function animate(){
document.getElementById('nos').style.backgroundPosition = '50% '+m+'px';
m--;
setTimeout("animate()",25);
}
//-->
</script>

</head>

<body onload="getReady();animate();">
...[/CODE]

it would be more efficient.

but it still consumes lots of memory, try changing the m-- and the line after it to something like
[CODE] m-=4;
setTimeout("animate()",100);[/CODE]

so that it doesnt have to run so often, and still get sort of the same result.

but still i dont thinks its very efficient :p
Copy linkTweet thisAlerts:
@ATBSauthorOct 20.2005 — Thanks for the help. You're right about the assignment. I made that change and it still flickers in IE. Changing the pixel increment and timing makes it too choppy.

I guess Flash is the way to go, eh?

Thanks again for the help saulss
×

Success!

Help @ATBS spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...