Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Denis McMahon Newsgroups: comp.lang.javascript Subject: Re: Quotes are trouble Date: Tue, 2 Oct 2012 03:21:11 +0000 (UTC) Organization: A noiseless patient Spider Lines: 57 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 2 Oct 2012 03:21:11 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="986f797cbd3b8f473a4775d73e9098bc"; logging-data="3435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KP1Au9N7Oag+sBTpnigpTHGgY3zrJ2qY=" User-Agent: Pan/0.136 (I'm far too busy being delicious; GIT 926a150 git://git.gnome.org/pan2) Cancel-Lock: sha1:SfxCyDWliEqj86mpuzOVRHOWXEE= Xref: csiph.com comp.lang.javascript:16306 On Mon, 01 Oct 2012 14:36:29 -0700, justaguy wrote: > What I want to do is, to seed and then replace an image every 500ms. > > HTML code: >
> > js code: > function popMain(img) { > document.getElementById('main').innerHTML = ""; > } > > function imgSlides() { > imgs = []; > imgs = > ['kn1.png','kn2.png','kn3.png','kn4.png','kn5.png','kn6.png']; > for (var i=0; i<6; i++) { > // alert(imgs[i]); > setTimeout(popMain(imgs[i]),500); > } > } > > > err msg: > missing quotes around argument? > > How do we fix the quotes? Thanks. Timestamp: 02/10/12 03:00:08 Error: Error: useless setTimeout call (missing quotes around argument?) Source File: http://www.sined.co.uk/tmp/popmain.htm Line: 19 This tells me that the error is in the "setTimeout" call, so check the syntax of that function. Looking at the syntax of that call, and googling for that function, the function name in the setTimeout call should be in quotes, or the params should be passed differently: setTimeout( "window.document.popMain(imgs[i])", 500 ); setTimeout( popMain, 500, imgs[i] ); However I was having problems with those, and there seems to be a lot of contradictory opinion on various websites - how unusual. So I tried to do looped images with a different approach at: http://www.sined.co.uk/tmp/popmain.htm Which seems to be working in my ubuntu/firefox, doesn't use innerHTML, uses dom node and element property manipulation. Rgds Denis McMahon