setTimeout not working on IE

J

James Black

I am trying to fade a word out, so after 5 seconds then every 1/4 sec
it should fade by a small amount, until it is gone.

This works fine in Firefox, but IE never calls the function that
setTimeout points to.

I am using IE 6, btw, on WinXP SP2.

browserdetect=savedspan.filters? "ie" : typeof
savedspan.style.MozOpacity=="string"? "mozilla" : "";
if (browserdetect=="mozilla") {
savedspan.style.MozOpacity = 1.0;
setTimeout(fadeSaved, 5000);
} else if (browserdetect=="ie") {
//alert("gradeSavedResult: inside the IE part");
savedspan.filters.alpha.opacity = 1.0; // This should only be used
in ie
window.setTimeout("fadeSaved()", 5000);
}


function fadeSaved() {
alert("fadeSaved: ");
}

I tried it with 'setTimeout(fadeSaved, 5000)' also, but that didn't
work.

Any idea why setTimeout wouldn't be working on IE?

Thanx.
 
L

Lee

James Black said:
I am trying to fade a word out, so after 5 seconds then every 1/4 sec
it should fade by a small amount, until it is gone.

This works fine in Firefox, but IE never calls the function that
setTimeout points to.

I am using IE 6, btw, on WinXP SP2.

browserdetect=savedspan.filters? "ie" : typeof
savedspan.style.MozOpacity=="string"? "mozilla" : "";
if (browserdetect=="mozilla") {
savedspan.style.MozOpacity = 1.0;
setTimeout(fadeSaved, 5000);
} else if (browserdetect=="ie") {
//alert("gradeSavedResult: inside the IE part");
savedspan.filters.alpha.opacity = 1.0; // This should only be used
in ie
window.setTimeout("fadeSaved()", 5000);
}


function fadeSaved() {
alert("fadeSaved: ");
}

I tried it with 'setTimeout(fadeSaved, 5000)' also, but that didn't
work.

Any idea why setTimeout wouldn't be working on IE?

It should be easy enough to convince yourself that setTimeout()
is working. It's probably your fadeSaved() function that doesn't
work in IE.

<html>
<body>
<script type="text/javascript">
setTimeout("alert('setTimeout() works')",1000);
</script>
wait
</body>
</html>


--
 
R

Randy Webb

James Black said the following on 4/14/2006 1:27 PM:
I am trying to fade a word out, so after 5 seconds then every 1/4 sec
it should fade by a small amount, until it is gone.

This works fine in Firefox, but IE never calls the function that
setTimeout points to.

I am using IE 6, btw, on WinXP SP2.

You shouldn't indent your code that much, it makes it a pain to do
anything with when it gets wrapped.
browserdetect=savedspan.filters? "ie" : typeof
savedspan.style.MozOpacity=="string"? "mozilla" : "";

Problem #1: Browser Detection
<URL: http://jibbering.com/faq/#FAQ4_26 >

If you want to use MozOpacity then test for it. If you want to use
filters then test for them - not for something in a useless UA string.
if (browserdetect=="mozilla") {
savedspan.style.MozOpacity = 1.0;
setTimeout(fadeSaved, 5000);
} else if (browserdetect=="ie") {
//alert("gradeSavedResult: inside the IE part");
savedspan.filters.alpha.opacity = 1.0; // This should only be used
in ie
window.setTimeout("fadeSaved()", 5000);
}


function fadeSaved() {
alert("fadeSaved: ");
}

I tried it with 'setTimeout(fadeSaved, 5000)' also, but that didn't
work.

There may be something else in your code, that isn't posted, that is
interfering with it. Post a small sample page that demonstrates
setTimeout not working properly.

var myTimer = window.setTimeout(myFunction,2000)
function myFunction(){
alert('Inside myFunction')
}

But, you might prefer setInterval over setTimeout and then have a
counter that will clear the interval after enough time to finish the fade.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top