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


Groups > comp.lang.javascript > #16314

Re: Quotes are trouble

From Matt McDonald <matt@fortybelow.ca>
Newsgroups comp.lang.javascript
Subject Re: Quotes are trouble
Date 2012-10-02 12:43 -0400
Organization A noiseless patient Spider
Message-ID <k4f5l4$8cu$1@dont-email.me> (permalink)
References <c94def8d-8e83-4b79-a971-f6be4acb5f84@r7g2000yqa.googlegroups.com>

Show all headers | View raw


On 01/10/12 17:36, justaguy wrote:

> What I want to do is, to seed and then replace an image every 500ms.

Instead of replacing an image, consider modifying its `src` property.

> HTML code:
> <div id="main"></div>

To implement such a strategy, author the image directly into the HTML
source. Then access the image via the DOM API. Consequently only one
element is ever created; and if properly authored, the image will be
usable to clients with JavaScript disabled.

>setTimeout(popMain(imgs[i]),500);

You are immediately invoking the function entitled `popMain'. Since it
does not return a function, when the time to invoke a callback arrives,
an error may be thrown. Instead, consider passing the parameter to a
function that will generate a callback as follows:

function createImageCallback(
         img
)
{
         return function () {
                 var el = img;
                 // code here
         };
}

function createImageTimer(
         img
)
{
         [global object].setTimeout(
                 createImageCallback(img),
                 500
         );
}

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


Thread

Quotes are trouble justaguy <lichunshen84@gmail.com> - 2012-10-01 14:36 -0700
  Re: Quotes are trouble Andrew Poulos <ap_prog@hotmail.com> - 2012-10-02 09:24 +1000
    Re: Quotes are trouble justaguy <lichunshen84@gmail.com> - 2012-10-01 17:01 -0700
  Re: Quotes are trouble Stefan Weiss <krewecherl@gmail.com> - 2012-10-02 02:21 +0200
    Re: Quotes are trouble justaguy <lichunshen84@gmail.com> - 2012-10-01 17:38 -0700
      Re: Quotes are trouble Stefan Weiss <krewecherl@gmail.com> - 2012-10-02 06:56 +0200
        Re: Quotes are trouble justaguy <lichunshen84@gmail.com> - 2012-10-03 21:33 -0700
          Re: Quotes are trouble "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-10-04 07:58 +0000
  Re: Quotes are trouble Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-02 03:21 +0000
  Re: Quotes are trouble Norman Peelman <npeelmandog@cfl.rr.com> - 2012-10-02 01:57 -0400
  Re: Quotes are trouble Matt McDonald <matt@fortybelow.ca> - 2012-10-02 12:43 -0400
  Re: Quotes are trouble Dr J R Stockton <reply1240@merlyn.demon.co.uk.invalid> - 2012-10-03 19:27 +0100
    Re: Quotes are trouble justaguy <lichunshen84@gmail.com> - 2012-10-03 21:34 -0700

csiph-web