🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #52019

Re: Co tu jest źle?

#52019
From: zpksoft
Date: Fri, 02 Aug 2019 12:48
65 lines
3703 bytes
W dniu czwartek, 1 sierpnia 2019 22:22:09 UTC+2 użytkownik Michal M. Lechanski napisał:
> Mam taki script w <body> (do head nie mam dostępu), który wyświetlał
> losowo jeden z obrazków. Ostatnio dodawałem kolejny obrazek i coś
> zepsułem - obrazki się nie wyświetlają. Poza tym wszystko inne działa.
> 
> Console z Developer Tools w Firefoksie pokazuje:
> 
> TypeError: document.getElementById(...) is null
>     loadHomeImage http://lechanski.net/:155
>     <anonymous> http://lechanski.net/:158
> 
> Podpowiedzcie proszę co zrobiłem źle i jak to naprawić.
> Z góry bardzo dziękuję.
> 
> 
> Kod:
> 
> <script type="text/javascript">
>  function loadHomeImage(){
>  console.log('loadHomeImage();');
>  var imagenumber = 11 ;
>  var randomnumber = Math.random() ;
>  var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
>  images = new Array;
> 	
> // LIST OF IMAGES
> images[0] ='<img src="http://images.fluidfolio.com/x/y/zzz1.jpg">';
> images[1] ='<img src="http://images.fluidfolio.com/x/y/zzz2.jpg">'
> images[2] ='<img src="http://images.fluidfolio.com/x/y/zzz3.jpg">';
> images[3] ='<img src="http://images.fluidfolio.com/x/y/zzz4.jpg">';
> images[4] ='<img src="http://images.fluidfolio.com/x/y/zzz5.jpg">';
> images[5] ='<img src="http://images.fluidfolio.com/x/y/zzz6.jpg">';
> images[6] ='<img src="http://images.fluidfolio.com/x/y/zzz7.jpg">';
> images[7] ='<img src="http://images.fluidfolio.com/x/y/zzz8.jpg">';
> images[8] ='<img src="http://images.fluidfolio.com/x/y/zzz9.jpg">';
> images[9] ='<img src="http://images.fluidfolio.com/x/y/zzz10.jpg">';
> images[10] ='<img src="https://images.fluidfolio.com/x/y/zzz11.jpg">';
> var image = images[rand1];
> captions = new Array;
> 
> // LIST OF CAPTİONS
> captions[0] = "Pictures: 01";
> captions[1] = "Pictures: 02";
> captions[2] = "Pictures: 03";
> captions[3] = "Pictures: 04";
> captions[4] = "Pictures: 05";
> captions[5] = "Pictures: 06";
> captions[6] = "Pictures: 07";
> captions[7] = "Pictures: 08";
> captions[8] = "Pictures: 09";
> captions[9] = "Pictures: 10";
> captions[10] = "Pictures: 11";
> var caption = captions[rand1];
> document.getElementById('homepage-image').innerHTML = '<img src="' +
> image + '" width="auto" height="400px">' + caption;    //linia 155
>    };
> 
> loadHomeImage();           //linia 158
> </script>
> 
> 
> -- 
> Michał

onload()
Technical Details
Message-ID: <aad393fc-9da9-4a86-8e3e-53b708a7f1eb@googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!3.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!b26no5348767qtq.0!news-out.google.com!a5ni916qtd.0!nntp.google.com!b26no5348765qtq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
References: <qhvhle$14p$1$michal@news.chmurka.net>

Show Full Headers
Complete Article Headers
X-Received: by 2002:a37:9cc2:: with SMTP id f185mr89978128qke.172.1564750139196;        Fri, 02 Aug 2019 05:48:59 -0700 (PDT)
X-Received: by 2002:a9d:2c09:: with SMTP id f9mr102068668otb.140.1564750138848; Fri, 02 Aug 2019 05:48:58 -0700 (PDT)
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!3.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!b26no5348767qtq.0!news-out.google.com!a5ni916qtd.0!nntp.google.com!b26no5348765qtq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: pl.comp.lang.javascript
Date: Fri, 2 Aug 2019 05:48:58 -0700 (PDT)
In-Reply-To: <qhvhle$14p$1$michal@news.chmurka.net>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=217.99.190.104; posting-account=8ND_mgoAAAD5J9y9fnaTB1Kcu7xKWk7Q
NNTP-Posting-Host: 217.99.190.104
References: <qhvhle$14p$1$michal@news.chmurka.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <aad393fc-9da9-4a86-8e3e-53b708a7f1eb@googlegroups.com>
Subject: Re: Co tu jest źle?
From: zpksoft <zpksoft@op.pl>
Injection-Date: Fri, 02 Aug 2019 12:48:59 +0000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit