473,574 Members | 2,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

settimeout() in IE

Can anyone help me. When I try to run next code I get message: Stack
overflow at line: 0. This only happens in IE while it works fine in Firefox.

<HTML>
<HEAD>
<TITLE>setTimeo ut example</TITLE>
<SCRIPT LANGUAGE="JavaS cript">
<!--
var dimages=new Array();
var numImages=2;
for (i=0; i<numImages; i++)
{
dimages[i]=new Image();
dimages[i].src="images/image"+(i+1)+". jpg";
}
var curImage=-1;

function swapPicture()
{
if (document.image s)
{
var nextImage=curIm age+1;
if (nextImage>=num Images)
nextImage=0;
if (dimages[nextImage] && dimages[nextImage].complete)
{
var target=0;
if (document.image s.myImage)
target=document .images.myImage ;
if (document.all && document.getEle mentById("myIma ge"))
target=document .getElementById ("myImage");
if (target)
{
target.src=dima ges[nextImage].src;
curImage=nextIm age;
}
setTimeout("swa pPicture()", 5000);
}
else
{
setTimeout("swa pPicture()", 500);
}
}
}
setTimeout("swa pPicture()", 5000);
//-->
</SCRIPT>
</HEAD>
<BODY>
<img src="images/image2.jpg" onLoad="swapPic ture()" name="myImage">
</BODY>
</HTML>
Mar 14 '06 #1
3 1915
VK

Danijel wrote:
Can anyone help me. When I try to run next code I get message: Stack
overflow at line: 0. This only happens in IE while it works fine in Firefox.

<HTML>
<HEAD>
<TITLE>setTimeo ut example</TITLE>
<SCRIPT LANGUAGE="JavaS cript">
<!--
var dimages=new Array();
var numImages=2;
for (i=0; i<numImages; i++)
{
dimages[i]=new Image();
dimages[i].src="images/image"+(i+1)+". jpg";
}
var curImage=-1;

function swapPicture()
{
if (document.image s)
{
var nextImage=curIm age+1;
if (nextImage>=num Images)
nextImage=0;
if (dimages[nextImage] && dimages[nextImage].complete)
{
var target=0;
if (document.image s.myImage)
target=document .images.myImage ;
if (document.all && document.getEle mentById("myIma ge"))
target=document .getElementById ("myImage");
if (target)
{
target.src=dima ges[nextImage].src;
curImage=nextIm age;
}
setTimeout("swa pPicture()", 5000);
}
else
{
setTimeout("swa pPicture()", 500);
}
}
}
setTimeout("swa pPicture()", 5000);
//-->
</SCRIPT>
</HEAD>
<BODY>
<img src="images/image2.jpg" onLoad="swapPic ture()" name="myImage">
</BODY>
</HTML>


Is your picture an animated gif ? (just checking)

Mar 14 '06 #2
> Is your picture an animated gif ? (just checking)

No it's normal *.jpg picture.
Mar 14 '06 #3
Danijel wrote:
Can anyone help me. When I try to run next code I get message: Stack
overflow at line: 0. This only happens in IE while it works fine in
Firefox.

[...]
Your markup is not Valid, and follows nonsensical notions of hiding scripts.
if (dimages[nextImage] && dimages[nextImage].complete)


dimages[nextImage].complete is unreliable. For example,

new Image().complet e

evaluates to `true' in Firefox 1.5.0.1.

Do not use setTimeout() here, use the 'onload' event handler instead.
(It fires when the image was loaded.)

See also <URL:http://pointedears.de/scripts/test/hoverMe/>, which script
code you can use, free of charge (but donations are always welcome), if you
adhere to the terms of the GNU General Public License, version 2 or above
as described in the comment. An even more sophisticated version, that will
also be available as a library resource, is currently under construction.
PointedEars
Mar 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3047
by: Jupiter49 | last post by:
I'm trying to move pictures around on the screen, with a slight delay between the first picture and second picture (following onmousemove). When I add the setTimeout function I must be doing it wrong because the function that calculates the new coordinates for the picture returns 32 million and change instead of the coordinate. This causes...
3
14918
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
2
4640
by: Athanasius | last post by:
Could someone shed some light as to why the following setTimeout function will not work on the Mac IE5.2? It does however work on PC(Forefox,Netscape,IE) & Mac(Safari,Firefox). Here is the script, it should simply present an alert message after 5 seconds. Thanks. <html> <head> <script language="javascript"> function MsgTimer() { var self...
6
2240
by: Brent | last post by:
Is there any obvious reason why there's no delay in the execution of setting the id.style.display when this function gets called? function Hide(divId,timeout) { var id = document.getElementById(divId); setTimeout(id.style.display = 'none',timeout); } Thanks for any help.
12
5528
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. Foo = function(type) { this.num = 0; this.type = type this.trigger(); } Foo.prototype.trigger = function() {
28
5268
by: Andre | last post by:
Hi, Does anyone know whether the ECMA, or an other standard document, specifies a maximum for the value that can be pass to the setTimeOut() function in Javascript? Andre
4
5216
by: E | last post by:
I am having trouble with setTimeout working on a second call to the setTimeout function from a second page which is an html page. Here is the scenario. I have a web page and onload it calls a javascript function which calls setTimeout and will process a second javascript function "Warn" just before the session expires. The Warn...
6
10907
by: Max | last post by:
Hi, I'm not exactly sure why this doesn't work. I'm basically just trying a simple approach at a slide down div. function slide_div { setTimeout("document.getElementById('mydiv').style.length='10px';",1000);
15
3774
by: nikki_herring | last post by:
I am using setTimeout( ) to continuously call a function that randomly rotates/displays 2 images on a page. The part I need help with is the second image should rotate 3 seconds after the first image rotates. I cannot figure out how to accomplish the 3 second delay. My code is pasted below: function randPic(){ randPic1(); randPic2();
7
2399
by: Martin | last post by:
Can I have two setTimeouts running at the same time - with two different intervals? I want to start one timer and, before it times out, start another one I've tried this and they seems to interfer with one another.
0
7801
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7719
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7808
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5299
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3749
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1055
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.