<br><br>JS warning... please reload
JAVASCRIPT and
DYNAMIC CONTENT
4. Repositioning Using the "else" Command



  So far we have learned how to move content around the page in all directions and we have learned how to limit it.
Now you may be asking "What 'else' can we make it do once it reaches the limit?".

Good question... now we come to the else command.
When it reached its limit on the last page, it had to stop, because it didnt meet the condition needed to move. Now, by adding the else command it has an option; If it doesnt meet the conditions set, the else can have it do something else... pardon the pun (-:

Else
The following says, if table3 is less than 560 pixels from the left, then move it 10 pixels to the right....BUT...if table three IS 560 pixels from the left THEN put it at 100 pixels off the screen to the left.....Whereupon the first function is again performed. It is now less that 560 pixels from the left side of the screen and will move 10 pixels each click.

if (document.all.table3.style.posLeft < 560)
{document.all.table3.style.posLeft +=10}
else {document.all.table3.style.posLeft=-100}


So this table will go across the screen to the 560 pixel mark, at which point it will again appear on the left and go across the screen again.


onClick
In the last example we got rid of the rom buttons for a more traditional link. Now we get rid of the sound too, by using onClick only.

<a onClick="scrolldemo()"> Hold the button down to try it</a>:



Hold the button down to try it
Notice the lack of a clicking noise?

 
Grab the Codes here!

JS Lessons by Ken

1. Move div without limits
1. txt page ~ ~ ~ 1. c/c/p codes

2. Move div with limits
2. txt page ~ ~ ~ 2. c/c/p codes

3. Using a single function for multiple actions
3. txt page ~ ~ ~ 3. c/c/p codes

4. Repositioning using the else command
4. txt page ~ ~ ~ 4. c/c/p codes

5. Intro to the setTimeout. Using it to scroll a div
5. txt page ~ ~ ~ 5. c/c/p codes

6. DHTML
6. txt page ~ ~ ~ 6. c/c/p codes

7. More DHTML
7. txt page ~ ~ ~ 7. c/c/p codes

8. Visibility
8. txt page ~ ~ ~ 8. s/s/p codes

Tandem Tooters    Paulie's Interface NG