Re: Removing and event from the html code.



> That test would be more appropriately applied as:
>
> if (document.getElementById) {
> document.getElementById('tel').innerHTML = msg;
> } else if (document.all){
> document.all['tel'].innerHTML = msg;
> }

I know. I've since learnt that the document.all is for IE4 (and
possibly below) so it's been dropped. Also I've optimised the function
a bit further and got rid of a couple of extra lines.

> setTimeout is not guaranteed to run at precisely the interval specified.

I'm not too concerned about the granularity of the time period. With
the time specified when the page is generated and the time it takes to
download and render the page (at least 2 seconds with IE) the time will
be out by a few seconds anyway. Besides it is simply there as a
guideline.

> That seems rather pointless, why not just use m & s throughout the rest
> of the script, or use:

Well I've been looking around the net for an answer: I'm not too good
at JS - I'm a C++ programmer by trade and an example of passing
parameters back to a function used that method.

> Seconds are padded with a leading zero, why not the minutes too?

Haven't the foggiest. I never wrote the original code. Doesn't seem
necessary. In fact changing it so it does have a leading zero in front
of the minute looks weird.

> This ensures that your timer never expires (whether you use 00 or 0) -
> it is re-set to 60 minutes when it runs down. Why do you think you need
> 00 rather than 0?

Like I said earlier I inherited this script with the page. That
section has been subsequently rewritten and one of the tests removed.

> Here you pass the result of the function to window.onload - it is
> executed immediately, most likely before the rest of the page has loaded.

No. window.onload will only executed once the page has been fully
loaded. Not before.

> And what error message do you get? Something like 'object expected' or
> similar?

Actually I don't get an error message, but nothing is rendered.
Putting an alert as the first line of the function doesn't generate an
alert. JS Console in FF doesn't register anything either.

> Don't use HTML comment delimiters inside script tags, it can have
> unwanted side-effects and serves no useful purpose.

That is absolutely wrong. You can't validate your code without them.

> This assigns the *result* of running countdown to window.onload. Since
> it doesn't return anything, it isn't run onload. countdown is run
> immediately, and I suspect it works sometimes when in a .js file because
> the file loads slowly enough that by the time it is executed, the 'tel'
> element exists. If it doesn't, the script errors.

window.onload won't execute until the page has fully loaded.

My original question was how do I call a function with window.onload
with two parameters.

Using the local system time won't work. The tick can be run at
anytime. Currently it is hourly (set to server time which is a minute
off) but what if the tick was decided to be run half hourly or even
shorter?

Thanks, Graham Reeds

.



Relevant Pages

  • Re: newbie question: cant get script to execute
    ... I saved this in a script "process.bsh". ... The typical name for a shell script it .sh, and this is not a shell ... > I chmod to 777 and still get "cannot execute". ... the error message is distinct and far ...
    (comp.lang.perl.misc)
  • Re: A short but unsuccessful script for calling a Java app.
    ... >> I have written the following short script in SUSE Linux v9.3. ... The error message is: ... > execute the script, or is the error that it cannot find or execute the ... Stan Goodman ...
    (comp.lang.java.programmer)
  • Re: A short but unsuccessful script for calling a Java app.
    ... I have written the following short script in SUSE Linux v9.3. ... I see nothing wrong with either of its two lines, yet each line gets an error message. ... it is executable and that it contains the requisite first line, it refuses to run; when I type its name (from the directory in which it resides, I am informed that there is no such file. ... execute the script, or is the error that it cannot find or execute the script at all? ...
    (comp.lang.java.programmer)
  • Re: any idea what I did to my system? "missing name for redirect" error
    ... > Fix whatever script your shell is running and you edited. ... when I type 'source ~/.tcshrc' I get no error message. ... I type source foo and foo runs fine. ... to execute foo directly, or open up a new xterm window (thus executing ...
    (alt.os.linux)
  • Re: blue screen
    ... Enquire, plan and execute ... Background information on Stop Error message ...
    (microsoft.public.windowsxp.general)

Loading