473,569 Members | 2,870 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 1913
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
3046
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
14916
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
4639
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
5525
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
5262
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
5215
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
10906
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
3769
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
2397
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
7926
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. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
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
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
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
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
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

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.