wmschneider@noctrl.edu wrote:[color=blue]
> I am trying to make a progress animation so that the user knows that
> there files are correctly being checked in. Trying to animate papers
> moving from the computer to the server pics. I'm brand new at this
> language, however, I've been programming in C++ for awhile. This is my
> code for that part of it. And I call the startAnimation() function
> when the button finish is clicked on. Represented like: <INPUT
> TYPE="SUBMIT" NAME="SUBMIT" onclick ="startAnimation()" VALUE="Finish">[/color]
I can't agree that such stuff is of any use - I thought that's what
animated cursors were for. Besides, what if the user submits the form
without clicking the submit button? E.g. types some content and
presses enter?
[color=blue]
>
> <STYLE><!--[/color]
Since what follows appears to be JavaScript, perhaps you'd better put
it in a script element rather than a style element. And while we're at
it, let's include required attributes lest the validator coughs at us -
oh, and remove the HTML comment delimiter, it's very outdated and
potentially harmful:
<script type="text/javascript">
[color=blue]
> var NS4 = (document.layers) ? 1 : 0;
> var IE4 = (document.all) ? 1 : 0;[/color]
It's a good idea not to post with tabs, replace them with 2 or 4 spaces
for indents (I've replaced them with one space).
Search for 'feature detection' and 'browser sniffing'. The above is a
totally inadequate test given the purpose which it is put below. It
will also exclude a good percentage (20%? 30%?) of browsers that don't
support document.all or document.layers.
Probably 95% of browsers in use support document.getElementById, it is
a much better strategy to target those browsers by default and then
deal with the exceptions only as required.
There are recently posted examples of how to ensure a suitable outcome
using document.getElementById and still support document.all and
document.layers.
[color=blue]
>
> function startAnimation(){
> anim1 = new animation("paper");
> anim1.slideBy(320,2, 99, 50);
> }
>
> function animation(id) {
> this.element = (NS4) ? document[id] : document.all[id].style;[/color]
The above line will not do what I think you want it to do in any
browser. Guessing at your intention, and if support for
getElementById is used as proposed above, then this becomes:
this.element = document.getElementById(id);
[color=blue]
> this.active = 0;
> this.timer = null;
> this.path = null;
> this.num = null;
>
> this.name = id + "Var";
> eval(this.name + " = this");[/color]
Eval is almost never required and is nearly always completely
unnecessary. I can't see that it does anything here.
this.name = id + "Var";
[...]
[color=blue]
>
> function left() {
> return (NS4) ? this.element.left : this.element.pixelLeft;
> }
>
> function top() {
> return (NS4) ? this.element.top : this.element.pixelTop;
> }[/color]
Accessing the position of elements in a page varies from browser to
browser. Browse around quirksmode:
<URL:http://www.quirksmode.org/js/cross_dhtml.html>
The link is to a page on DHTML, but much of what it does is applicable
to your stuff here.
This highlights that the browser test above infers support for many
features based on testing just one method of one object - a very
unreliable strategy.
[...]
What do you expect will make the animation stop?
--
Zif