Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > pl.comp.lang.javascript > #3609

Re: Co tu jest źle?

Newsgroups pl.comp.lang.javascript
Date 2019-08-02 05:48 -0700
References <qhvhle$14p$1$michal@news.chmurka.net>
Message-ID <aad393fc-9da9-4a86-8e3e-53b708a7f1eb@googlegroups.com> (permalink)
Subject Re: Co tu jest źle?
From zpksoft <zpksoft@op.pl>

Show all headers | View raw


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()

Back to pl.comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Co tu jest źle? "Michal M. Lechanski" <michal@doriath.eu> - 2019-08-01 21:22 +0100
  Re: Co tu jest źle? Tomek <skowtm@wp.xx.pl> - 2019-08-02 09:25 +0200
  Re: Co tu jest źle? zpksoft <zpksoft@op.pl> - 2019-08-02 05:48 -0700
  Re: Co tu jest źle? "Michal M. Lechanski" <michal@doriath.eu> - 2019-08-03 09:46 +0100

csiph-web