+ 4

Why console is displaying error ??

Help me in fixing this error plzz. https://code.sololearn.com/WwW3UmbtSVGk/?ref=app

29th Oct 2018, 8:42 PM
Arushi Singhania
Arushi Singhania - avatar
8 Antworten
+ 2
I still can't see the background image. May be some problem with the link. Anyways, it's giving you error bcz the js part is getting loaded before the html part gets so it can't find that id "i1" that's why it's None. You need to put all your js code inside a function which will be called after the html window get loaded. It can be done as: window.onload = function(){ var images=["https://cdn.pixbay.com/photo/2016/10/21/08/39/halloween-1757492_960_720.jpg"]; var i1 = document.getElementById("i1"); var a =0; window.onload=setInterval(function() {i1.style.backgroundImage="url("+images[a]+")"; a +=1 ; if (a==images.length-1) { } },2000); } and now you don't need that inner window.onload.
29th Oct 2018, 8:52 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 7
Shashi Ranjan Thx for the help!!! I made a typo in img url. Now, I have fixed that.
29th Oct 2018, 9:03 PM
Arushi Singhania
Arushi Singhania - avatar
+ 6
No. I am working on looping just once. I will add more bg images and they will swipe after one another just for once. I was trying with one image at first only.
29th Oct 2018, 9:12 PM
Arushi Singhania
Arushi Singhania - avatar
+ 2
console is going nuts and bolts
29th Oct 2018, 8:45 PM
BroFar
BroFar - avatar
+ 2
tried running just the image url on the internet and it could not and would not answer call
29th Oct 2018, 8:51 PM
BroFar
BroFar - avatar
+ 2
ok as long as we are on the same page just as using a carousel with one image then filling in ~ more images
29th Oct 2018, 9:15 PM
BroFar
BroFar - avatar
+ 2
Arushi Singhania yea, now I can see some backgrounds changing.👍
30th Oct 2018, 3:31 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 1
Did you mean for it to connect / flash and disappear
29th Oct 2018, 9:09 PM
BroFar
BroFar - avatar