Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26747

Re: Problem determining iFrame source url ...

From Tim Streater <timstreater@greenbee.net>
Newsgroups comp.lang.javascript
Subject Re: Problem determining iFrame source url ...
Date 2015-01-29 13:39 +0000
Message-ID <290120151339129330%timstreater@greenbee.net> (permalink)
References <c47f984c-b560-4c77-ac64-09a08a43ada7@googlegroups.com>

Show all headers | View raw


In article <c47f984c-b560-4c77-ac64-09a08a43ada7@googlegroups.com>,
sean mc <seanmc1217@gmail.com> wrote:

>I found code (someone elses code posted to another blog somewhere or other)
>that would change an iframes src attribute after a timed period. When used as
>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 ??

-- 
"That which can be asserted without evidence, can be dismissed without 
evidence."
-- Christopher Hitchens

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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