Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #26749
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Problem determining iFrame source url ... |
| Date | 2015-01-29 15:04 +0100 |
| Organization | solani.org |
| Message-ID | <madelm$r7p$1@solani.org> (permalink) |
| References | <c47f984c-b560-4c77-ac64-09a08a43ada7@googlegroups.com> <290120151339129330%timstreater@greenbee.net> |
Tim Streater wrote:
> In article <c47f984c-b560-4c77-ac64-09a08a43ada7@googlegroups.com>,
> sean mc <seanmc1217@gmail.com> wrote:
>
>> below, it works fine....sort of... :
>> --------------------------------------------------------
>> <script type="text/javascript">
>> function ChangeSrc() {
>> var frames = Array('splash.html', 4,
>> 'data.html');
>> var i = 0, len = frames.length;
>> document.getElementById('data_frame').src = frames[i++];
>> if (i >= len) return; // no more changing
>> setTimeout('ChangeSrc()', (frames[i++]*1000));
>> //}
>>
>> window.onload = ChangeSrc;
>> </script>
>> --------------------------------------------------------
>
> In this function, i is declared (var i = 0), incremented (by the i++),
> and then compared with len.
>
> I can't see why i would ever have a value other than 1 when this
> statement:
>
> if (i >= len) return; // no more changing
>
> is executed. The same is true of your function. So what is the point of
> the variable i or indeed the test to compare with len ??
I guess that i is supposed to be declared outside of ChangeSrc().
However, as the code has a syntax error anyway (the function body is not
terminated with }), all bets are off -- and certainly, it does not work
fine.
--
Christoph M. Becker
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-29 05:20 -0800
Re: Problem determining iFrame source url ... Tim Streater <timstreater@greenbee.net> - 2015-01-29 13:39 +0000
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-29 05:58 -0800
Re: Problem determining iFrame source url ... "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-29 15:04 +0100
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-29 06:25 -0800
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-29 06:31 -0800
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-29 08:09 -0800
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-29 08:22 -0800
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-29 16:14 -0800
Re: Problem determining iFrame source url ... "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-30 10:25 +0100
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-30 06:53 -0800
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-30 12:45 -0800
Re: Problem determining iFrame source url ... "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-30 23:25 +0100
Re: Problem determining iFrame source url ... "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-30 23:57 +0100
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-30 17:53 -0800
Re: Problem determining iFrame source url ... sean mc <seanmc1217@gmail.com> - 2015-01-30 17:59 -0800
csiph-web