Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #26760
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Problem determining iFrame source url ... |
| Date | 2015-01-30 23:57 +0100 |
| Organization | solani.org |
| Message-ID | <mah27o$jb3$1@solani.org> (permalink) |
| References | <c47f984c-b560-4c77-ac64-09a08a43ada7@googlegroups.com> <df2ae8b0-c46e-4e6f-a4c4-de35c757bdbe@googlegroups.com> <XnsA432EE38BA683eejj99@194.109.133.246> |
Evertjan. wrote:
> var frames = ['test1.html', 2, 'test2.html', 3, 'test3.html'];
> var i = 0;
>
> function ChangeSrc() {
> var iFrm = document.getElementById('data_frame');
> iFrm.src = frames[i++];
> if (i < frames.length)
> setTimeout(ChangeSrc, (frames[i++]*1000));
> };
>
> window.onload = ChangeSrc;
I would suggest to put this code inside an IIFE, to avoid (inadvertent)
modifications of `frames` or `i` from other scripts:
(function () {
// ...
}());
--
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