Image changer..

B

Barely Audible

Anyone any suggestions for a script that will change an image in an html
page at regular intervals?

--
TTFN
Jim

The one item you need is always in short supply.
-- Murphy's Military Laws, #41
 
R

rf

Barely said:
Anyone any suggestions for a script that will change an image in an
html page at regular intervals?

Yes. None. Don't do it.

Such changing stuff draws the attention of the viewer away from the actual
content of the page, assuming the page actually has some content.
 
E

Evertjan.

Barely Audible wrote on 06 jun 2009 in comp.lang.javascript:
Anyone any suggestions for a script that will change an image in an html
page at regular intervals?

There are thousands of javascript slideshows on the web on the web,
most are not exactly what you want, are very badly written.

So write one yourself having mastered some Javascript,
or pay for a professional to help you.
 
T

Thomas 'PointedEars' Lahn

Barely said:
Anyone any suggestions for a script that will change an image in an html
page at regular intervals?

Yes. What have you tried?


PointedEars
 
V

VK

I expected someone to come up with junk like this, and when I noticed
your haunting this group again, I was certain that would include you.

Did you write or do you know a better one? Do not hesitate to share
it. c.l.j. is open for anyone posting - even for you.

As a side not I did not claim that it is the best out of all or an
absolutely reliable script. I just pointed to the script that
seemingly does what OP seemingly wants. What problem do you have with
that?
 
T

The Natural Philosopher

VK said:
Did you write or do you know a better one? Do not hesitate to share
it. c.l.j. is open for anyone posting - even for you.

As a side not I did not claim that it is the best out of all or an
absolutely reliable script. I just pointed to the script that
seemingly does what OP seemingly wants. What problem do you have with
that?

It doesn't have pointed ears?

Nuff said.
 
T

Thomas 'PointedEars' Lahn

VK said:
Did you write or do you know a better one? Do not hesitate to share
it. c.l.j. is open for anyone posting - even for you.

False dilemma. If a thing has properties that are objectively bad enough
that it should not be used, there is no need to prove that a better thing
exists in order not to use the first thing.

BTW, your being only an infrequent nuisance around here make your attempts
at patronizing me of all people, arguably a longtime regular to this
newsgroup, look rather ridiculous.
As a side not I did not claim that it is the best out of all or an
absolutely reliable script. I just pointed to the script that
seemingly does what OP seemingly wants. What problem do you have with
that?

If you would not think that this can or should be used, you would not post
it without comment. That is the problem.


PointedEars
 
B

Barely Audible

if I come on this newsgroup again someone shoot me....

--
TTFN
Jim

The best armor is staying out of gun-shot.
-- Italian proverb
 
T

Thomas 'PointedEars' Lahn

Barely said:
if I come on this newsgroup again someone shoot me....

Just say so and I'll call the people with the huge black van to come for you.


PointedEars
 
L

Lasse Reichstein Nielsen

Barely Audible said:
if I come on this newsgroup again someone shoot me....

Can't blame you, although a good killfile will go a long way.

And, just for the record:

function slideshow(imageId, interval, imageUrls) {
var counter = 0;
return setInterval(function() {
counter = (counter + 1) % imageUrls.length;
var img = document.images[imageId];
img.src = imageUrls[counter];
}, interval);
};

Use as, e.g.,

<img id="ssimg" src="img1.png">
<script type="text/javascript">
// Call directly, or in an onload event handler.
slideshow("ssimg", 5000, ["img1.png", "img2.png", "img3.png"]);
</script>

This changes the src of the image element every five seconds.
It starts at the second image in the list, assuming that the first one
is being displayed by default. If you want it to start at the first URL,
move the counter increment to the end of the function instead of the start.

If you ever need the slideshop to stop, remember the return value and
call clearInterval with it as argument.

/L
 
T

Thomas 'PointedEars' Lahn

Conrad said:
Thomas said:
Just say so and I'll call the people with the huge black van to come
for you.

Yes. Shoot the newbie, great idea. If you continue to drive away people
who come here asking for advice, don't be surprised when they turn to a
subpar solution like dynamicdrive or JQuery. [...]

Your Irony Detector[tm] is borken.


PointedEars
 
S

SAM

Le 6/6/09 2:03 PM, Barely Audible a écrit :
Anyone any suggestions for a script that will change an image in an html
page at regular intervals?

for 10 images named '1.jpg' to '10.jpg' :

JS:
===
var imgsIdx = 1;
function chgeImg() {
var I = document.images&&document.images.viewer?
document.images.viewer :
document.getElementById('viewer')?
document.getElementById('viewer') :
null;
imgsIdx++;
if(imgsIdx>10) imgsIdx = 0;
if(I) I.src = imgsIdx + '.jpg';
}
window.onload = setInterval('chgeImg()', 3000);

HTML:
=====
<img name="viewer" id="viewer" src="1.jpg">
 
T

Trevor Lawrence

I am with you, Conrad.

I may have tried to write something (if I dared on this elite group) but
your code looks great for a 2-minute effort.

From a person obviously not as expert in JavaScript as "Pointed Ears" or as
Conrad.

I wonder who is better at sharing their expertise?
(The question is rhetorical).
--
Trevor Lawrence
Canberra
Web Site http://trevorl.mvps.org

Conrad Lender said:
Just say so and I'll call the people with the huge black van to come
for you.

Yes. Shoot the newbie, great idea. If you continue to drive away people
who come here asking for advice, don't be surprised when they turn to a
subpar solution like dynamicdrive or JQuery. He's probably not reading
this group anymore (and after those replies, I don't blame him), but for
the record, here's a possible solution to his problem (untested):

<img src="foo.jpg" id="myImg" ....>

<script type="text/javascript">

var imgSrcList = [
"foo.jpg",
"bar.jpg",
"baz.jpg"
],
i = 0,
delay = 3000,
img;

function nextImg () {
img.src = imgSrcList[++i % 3];
window.setTimeout(nextImg, delay);
}

if ("getElementById" in document
&& "setTimeout" in window
&& (img = document.getElementById("myImg")))
{
window.setTimeout(nextImg, delay);
}

</script>

That took all of 2 minutes. I don't think the OP was unreasonable in
hoping for at least one helpful reply.


- Conrad
 
J

Jeff

VK said:
Really sorry for all this. Good luck in your project.


Well, Thomas may not be the most likable fellow, but he is right.

Your "solution" does not answer the OPs question, the OP asked for an
image changer while yours rewrites a div and would need adapting. It
also loads a huge amount of bloated code and requires a lot of set up.
All totally unneeded.

The real solution is simple, but requires some initial effort be put
out by the OP.

What you have done is encourage the OP to always take the spoon fed
answer, and to disparage anyone who is actually trying to teach them to
fish. All this does is create another whining slacker who will just
haunt somewhere else for the non solution.

Not the first time I have seen this.

Jeff
 
V

VK

   Your "solution" does not answer the OPs question, the OP asked foran
image changer while yours rewrites a div and would need adapting. It
also loads a huge amount of bloated code and requires a lot of set up.
All totally unneeded.

So keep handy a set of scripts you personally like for js-trivia
(slide show, collapsing menu lists etc.) and post them.
   The real solution is simple, but requires some initial effort be put
out by the OP.

   What you have done is encourage the OP to always take the spoon fed
answer, and to disparage anyone who is actually trying to teach them to
fish. All this does is create another whining slacker who will just
haunt somewhere else for the non solution.

   Not the first time I have seen this.

And not the last, let me assure you on that. You see, the teaching is
needed when asked, not because one self-appointed himself to teach the
entire world. OP asked for a "suggestions for a script", not how to
write a script or how to learn Javascript in the most effective way.
What do you know about this person and why are you so sure that he has
to learn the language? There are (at least they were here before)
people just willing to put some family photos or school photos on
their site as a slide show. Why the hell they need to learn Javascript
just to eventually write yet another 1,000,001st variant of the
script? If OP states something like "I am learning JavaScript and..."
or "I am playing around with JavaScript and..." then go ahead.
Otherwise this Asian market like crowd of "fishing stick sellers"
scares sh*t out of newcomers. ;-)
 
J

Jeff

VK wrote:
<snip>

e non solution.
And not the last, let me assure you on that. You see, the teaching is
needed when asked, not because one self-appointed himself to teach the
entire world.

There are plenty of forums where such information can be exchanged.
Historically the use of usenet has been a bit different. Particularly in
any of the comp.lang groups.

I think it's best not to cheapen and waste such a valuable resource
than to cater to what can be found in thousands of other places.

Have you ever read the FAQ for this group?:

http://www.jibbering.com/faq/

Note the bit about what to do before you post.


OP asked for a "suggestions for a script", not how to
write a script or how to learn Javascript in the most effective way.


This not a forum, this is usenet. It's a great place to learn from
some very sharp people. When you lower it to a lazy mans resource you
remove the incentive for experts to hang out here.

Jeff
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top