HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Slideshows how to anyone?
Post new topic   Reply to topic    HTML Help Forum Index -> General HTML
View previous topic :: View next topic  
Author Message
Devante



Joined: 19 Jul 2008
Posts: 5

PostPosted: Sun Jul 20, 2008 7:41 pm     Slideshows how to anyone? Reply with quote

I am new to web design and i am making a business web site. I am wanting to have a nice slideshow maybe something of different projects i have done one fading to another. 10 or so pictures i think would be adequate. Can anyone steer me in the right direction for this and as i am new to this the easier to understand the better.

Thanks in advance,

Devante
Straystudio



Joined: 14 Apr 2008
Posts: 261
Location: Nord Italy

PostPosted: Mon Jul 21, 2008 8:44 pm     Starting an Array Reply with quote

It is fine You also wish to understand, not to copy-paste only.

Every JavaScript slideshow coding employs

setTimeout('',) or setInterval('',)

beeing Operative Sistem's native JavaScript properties, kind of timers, taking cadence through the computer's built-in clock.
This is what automatically moves the "gear"; a gear which has to stand-up by itself handling Images, though.
Timer intervenes after, on this gear.


Now, how to store the Images.
Images are called in play through their address ending .jpg .gif or so; and this will be kept, still.
Yet, the coding "gear" We are going to accomplish, is able to slide along a list through math operators; namely here, "+" plus operator.
We can not have the program "understanding" the string of the Image URL, but We can translate each URL into a numbered item of a group.

It is what is called an Array, in programming.
You can write Your Array this way:
Code:


<script type="text/javascript">

aWord = new Array()
aWord[0] = ""
aWord[1] = ""
aWord[2] = ""
aWord[3] = ""
// and go on ...
</script>



Any Array starts listing by zero; so, aWord[0] actually is the number one item of the Array.
This is a 4 items Array; between the double quotation mark, the Images' URL can find their places.
(They could also be couples of single quotes).
Of course, other values than URLs, as well can be stored in an Array().
The declaration = new Array() must always be present, to let the system "understand" the Programmer is listing items as an Array.
So, let's write the Array We need:
Code:

<script type="text/JavaScript">

pictures = new Array()
pictures[0] = "http://www.cameraworkphotographers.com/002ITALIA.jpg";
pictures[1] = "http://www.cameraworkphotographers.com/008ITALIA.jpg";
pictures[2] = "http://www.cameraworkphotographers.com/003ITALIA.jpg";
pictures[3] = "http://www.cameraworkphotographers.com/001ITALIA.jpg";

</script>



The good is, now every URL can be accessed by handling
pictures[0]
pictures[1]
...
where the number is the only thing to change; and this can work with math operators.
Great!


So, test it.
Have an img Element in the BODY, and give it an id identifier (as JS will have to be able to individuate it):
Code:
<img id="displayer" src="" />

Be aware, src="pictures[2]" can't work; these pictures[n] items must be drived to the id-provided Element via JavaScript.

You can either leave src="" as empty, or enter any URL; and either nothing or that Images will be displayed once page loaded.
It does not matter, this JS string will be able to change SRC value:

document.getElementById("displayer").src=pictures[n]

And this wants to be a short Document for testing:
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Testing Array</title>

<script type="text/JavaScript">

pictures = new Array()
pictures[0] = "http://www.cameraworkphotographers.com/002ITALIA.jpg";
pictures[1] = "http://www.cameraworkphotographers.com/008ITALIA.jpg";
pictures[2] = "http://www.cameraworkphotographers.com/003ITALIA.jpg";
pictures[3] = "http://www.cameraworkphotographers.com/001ITALIA.jpg";

function displayIMG() {
    document.getElementById("displayer").src=pictures[1];
    }

</script>

</head>
<body bgcolor="#444440" text="#ffffff">
<br />
<br />

<a href='javascript: displayIMG();' style="font-size: 20px; color: #ffffff;">Get Image URL</a>


<div align="center">

<img id="displayer" src="" />

</div>


</body>
</html>



Under the function, change pictures[1] into an other number, and the corresponding pictures stored in the Array, will appear.



What We have reached at now, besides a good level at studying purpose, also is how displaying via JavaScript, different Images on given place(s) along an HTML page, thanks to a serie of these kind of JS Links; the alternate way to achieve that, is IFRAME.
Otherwise, employing classic Links, You are forced to get more new opening windows where Images appear; or to take them in the same window, yet navigating away from the master page.
As a way else, JS also allows to open a new customized-size window (pop-up) over the window where the master page is, to display Images or what, without blurring or leaving the master page at all.

Now, let Me come back to the slideshow argument again.
I want to change that Array item number without editing the Document, of course.
I'll develop the above displayIMG() function into this:


facing = 0

pictures = new Array()
pictures[0] = 'http://www.cameraworkphotographers.com/002ITALIA.jpg';
pictures[1] = "http://www.cameraworkphotographers.com/008ITALIA.jpg";
pictures[2] = "http://www.cameraworkphotographers.com/003ITALIA.jpg";
pictures[3] = "http://www.cameraworkphotographers.com/001ITALIA.jpg";

function displayIMG() {
    shown = facing +1
    document.getElementById("displayer").src=pictures[shown];
    facing = shown
    }


Firstly, note I have changed the item number between the [] square brackets into a service word: shown (You could also write George, as service word).

The function now, starts with a statement: shown = facing +1
and I declared a first value as "facing", above in the SCRIPT: facing = 0

So, on the function beeing called by the Link, the actual numeric-value of "facing" word, increases by +1 and goes passed into the [] brackets as "shown"; finally, "shown" translates into a number, in pictures[shown] at coding effect.
Once this string is processed (JS is run likewise We read it, from top to bottom) and that given Array item is delivered to the img Element as value of src Attribute, further a statement is encountered as final act of the function: facing = shown
this mean, on the next time the function will be called by the Link, "facing" will be no longer translating into "0", into "1" instead at the beginning of the processing.
As a result, "shown" increases by +1 on every time the Link is clicked.

And the text of the Link should change accordingly, from "Get Image URL" into "Browse Images".

A reverse browsing back also is possible, simply duplicate function and Link, where the only things to modify are the operator, -1 in place of +1, and of course, a different name for each function.


A name of a function can be letters or numbers and must start with letter; no punctuation than " _ " nor empty spaces.


Now what is worth to be relieved, is the browsing ends when the last item is reached; indeed, "shown" still goes increasing by +/- 1 on each click, the highest and the lowest items beeing 3 and 0, even though.

What is needing, instead beeing aimed to build a slideshow, is to keep the browsing process as rotating ...


( To be continued; I'll keep posting. )
 
Jetsam4996



Joined: 03 May 2008
Posts: 22

PostPosted: Sat Jul 26, 2008 2:45 pm     Reply with quote

ummm, well, to do it without complicated coding, you may just want to download a software such as photobucket, and create your slideshow, then embedd it into your site.

glad to help,
jetsam4996
Straystudio



Joined: 14 Apr 2008
Posts: 261
Location: Nord Italy

PostPosted: Fri Aug 01, 2008 2:11 am     basic autostart Slideshow JavaScript Code Reply with quote

This won't be anything complicated, just HTML Coding as this Forum is designed to; 'pieces' of JavaScript, Users can accomplish according to their layouts.


  if STATEMENT IN JAVASCRIPT

if (hypothesis) {string to be executed if hypothesis occurs}


Now We need that:

if the item-number facing to income into the function, as increased as left on the last triggering, matchs already the last item of the Array, 3 in this sample and going to produce 4 so overtaking Array length, if so We no longer want it to take +1
We simply want to take 0 zero, istead to be delivered as shown in the command JS path directly; the first pitcure of the Array going to be displayed again.

Otherwise, the last item beeing not reached, still (else) +1 goes to be added to get the number, shown will translate into.



pictures = new Array()
pictures[0] = "http://www.cameraworkphotographers.com/002ITALIA.jpg";
pictures[1] = "http://www.cameraworkphotographers.com/008ITALIA.jpg";
pictures[2] = "http://www.cameraworkphotographers.com/003ITALIA.jpg";
pictures[3] = "http://www.cameraworkphotographers.com/001ITALIA.jpg";

    facing = -1

function SwapAhead() {
    if (facing == 3) {
    shown = 0}
    else {
    shown = facing +1
    };
    document.getElementById("displayer").src=pictures[shown];
    facing = shown
    };



And yes, this makes an handler able to keep the change of image as rotating.

Also notice, I have changed the opening facing = 0 declaration into facing = -1 so to have the first image pictures[0] to show on the very first click, since it is assumed here to have img src"" empty in the BODY (blank page on loading); otherwise, its URL can be placed there. This is matter of choices in building.


Now the next step, how to finally automate the swapping of images, will be way more easy than anyone could expect.
Simply add this Timer as further a command along the "staircase" of the function:

setTimeout('SwapAhead()', 2000)

where 2000 is the amount in milli-seconds (customizable) after of that, the content between '' quotes will be executed; here, calling the function itself to auto-trigger.

As a result, a complete basic slideshow project; care of, I changed the name of the function into Sequence() :
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Basic Autostarting Slideshow Layout</title>


<script type="text/JavaScript">

pictures = new Array()
pictures[0] = "http://www.cameraworkphotographers.com/002ITALIA.jpg";
pictures[1] = "http://www.cameraworkphotographers.com/008ITALIA.jpg";
pictures[2] = "http://www.cameraworkphotographers.com/003ITALIA.jpg";
pictures[3] = "http://www.cameraworkphotographers.com/001ITALIA.jpg";


    facing = -1

 function Sequence() {

    if (facing == 3) {
    shown = 0}
    else {
    shown = facing +1
    };

    document.getElementById("displayer").src=pictures[shown];
    facing = shown

    setTimeout('Sequence()', 2000);

 };

</script>

</head>
<body bgcolor="#444440" text="#ffffff" onLoad='Sequence()'>


<table height="100%" width="100%"><tr>
 <td align="center" valign="middle">

   <img id="displayer" src="" />

 </td></tr>
</table>


</body>
</html>


Here the starting input turning the function to run, is given by:

onLoad='Sequence()'

handler of Event entered in the opening BODY Tag.
This slideshow features autostart, then.

onLoad acts likewise a button, automatically pushing itself once the page has completed downloading.


But wait, what if We want to to stop the gear?
A stopping command can be carried out through:

clearTimeout()

native JS property designed to stop setTimeout('', ) Timers; it does also exist:

clearInterval() to stop setInterval('', ) Timers.

Naming is required, as more Timers may exist in a same SCRIPT.
So, look at how sintax can be:

T10 = setTimeout('Sequence()', 2000) // in the JS function

and a trigger alike, in the BODY:
Code:
<input type="button" value="STOP" onClick='clearTimeout(T10)' />


with of course, to re-start slideshow:
Code:
<input type="button" value="START" onClick='Sequence()' />



A complete range of commands can be accomplished by adding gears, too to manually browse images ahead and back, once slideshow has stopped.
This is the next layout I will be posting.


Before, let me consider .length JS property returning how many items an Array extends by; in Our current sample, it returns 4 as pictures.length

In the Array storing images, You may add others as many as You wish.
As a consequence, You had to edit the corresponding integer number in the if-statement of one function or more.

So, in place of:

if (facing == 3) {   // to be manually revised

You can write:

if (facing == (pictures.length -1) ) {   // auto-revising

This is very helpful to shape kind of SCRIPT, the User has not to edit inside running the risk of omissions or damage: editing will act just at Array level, also concerning some variables else, if any; still placed aside at the top of the SCRIPT.
Among variables at the beginning of the SCRIPT, it is good to have the amount of milli-sec. driving setTimeout Timer; and nothing editable else remains below the Array line.


<script type="text/JavaScript">

        tickspeed =
2000 // set in milli-seconds: 2000 = 2sec.; 6500 = 6.5 sec.

  pictures = new Array()

        ( SCRIPT CONTINUES )


        setTimeout('Sequence()', tickspeed);


Wishing to have it to be written in seconds directly, as more friendly, a multiplier can go along with tickspeed; in JavaScript, * sign acts as multiplier, as well as x or · are used in classic math.

        tickspeed = 2 // set in seconds.

        setTimeout('Sequence()', tickspeed
*1000);   // Timer actually takes 2000 as milli-sec.


At this point, let me remind / divisor in JS, so all four the operations can be done, now:
        + - * /
act as:
        + - x :

  ==
  =   



 
Newbie101



Joined: 09 Oct 2008
Posts: 35

PostPosted: Fri Oct 10, 2008 6:12 pm     make animated GIF Reply with quote

Suprised nobody has mentioned animated GIFs.

a) download a free program called unfreez from Majorgeeks or somewhere.

b) size all photos the same and save as GIF files (will result in some resolution loss), but not too bad.

c) Put them all together with unfreez and pick a time delay.

I have made animations and animated buttons with this method. It is easy and a GIF file is accessed the same way as a JPEG.

The other methods are better for high quality, but all data is stored within the GIF file so there is no need for tons of code and simplicity is better sometimes.
biffnewport



Joined: 30 Sep 2007
Posts: 10

PostPosted: Sun Oct 12, 2008 5:56 pm     Reply with quote

You could upload your pictures to Picasa and then make a slide show there.

While signed in to Picasa, open the Web Album you created and click on "Link to this post." Then click on "Embed slideshow". Copy and paste the code to your page.

You may want use a <DIV> tag to align your slideshow.

Something like this.

<DIV ALIGN="CENTER>

<embed code goes here></embed>

</DIV>

If you would like to use the animated gif method previously mentioned you can create the animation with Photoscape, a great free download which allows you to add frames and transitions to your anigif.
Newbie101



Joined: 09 Oct 2008
Posts: 35

PostPosted: Sun Oct 12, 2008 6:11 pm     sample of my animated gifs Reply with quote

yes! the program I used called unfreez is fairly limited as all the pics need to be spaced the same way timewise. I'd suggest the other program if its free.

I have a very old geocities site that has decent examples of what effects it does. I even used an animated gif as a background which gives a great background changing effect I've not seen elsewhere. The background changes colour every 10 secs or so.

I don't want to be accused of spamming so I'll mention that this (very old) wedding website page is still around on geocities for some strange reason (5 years). I stopped doing wedding websites when software came down to twenty bucks that did a better job than me. lol

here it is though its worth anyone looking at the background effect though
http://geocities.com/friendlyprogrammer/msg5.htm?200617

think photobucket.com also does slideshows.

Sorry I'm giving newb answers, but I just seem to like animated gifs. lol
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> General HTML All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial