Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by 9apit
at 2024-07-24 09:01:32
Point:500 Replies:3 POST_ID:829091USER_ID:11723
Topic:
JavaScript;;
Hello expert,
Got the code copied below to work, sort of.
It displays the first image and goes to the second
but won't advance to the third.
Any idea why it is hanging?
Thanks
Allen in Dallas
Got the code copied below to work, sort of.
It displays the first image and goes to the second
but won't advance to the third.
Any idea why it is hanging?
Thanks
Allen in Dallas
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- from http://stackoverflow.com/questions/3264739/image-change-every-30-seconds-loop --> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript">var images = new Array()images[0] = "shared_vision_spirit.jpg";images[1] = "shared_vision_clear.jpg";images[2] = "shared_govern.jpg";setTimeout("changeImage()", 1000);var x=0;function changeImage(){document.getElementById("img").src=images[x]x++;} </script> <img id="img" src="shared_vision.jpg"> </body></html> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:
Author: 9apit replied at 2024-07-24 09:29:31
Hello Gary,
Thanks.
Allen in Dallas
Thanks.
Allen in Dallas
Accepted Solution
Expert: Gary replied at 2024-07-24 09:20:48
500 points EXCELLENT
That should be setInterval not setTimeout
And then you need a check if x is greater than the numer of array elements.
And it helps to markup your page correctly
And then you need a check if x is greater than the numer of array elements.
And it helps to markup your page correctly
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script>var images = new Array()images[0] = "shared_vision_spirit.jpg";images[1] = "shared_vision_clear.jpg";images[2] = "shared_govern.jpg";setInterval("changeImage()", 1000);var x=0function changeImage(){document.getElementById("img").src=images[x]x++;if (x>2) x = 0} </script></head><body> <img id="img" src="shared_vision.jpg"> </body></html> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:
Expert: duncanb7 replied at 2024-07-24 09:18:32
Did you check your javascript error on developer tools ?
The third one image file might not exist in the directory you
are running the web page
Click on the developer tools, and click console that you will see the error if any
What browser are you using ?
Duncan
The third one image file might not exist in the directory you
are running the web page
Click on the developer tools, and click console that you will see the error if any
What browser are you using ?
Duncan