+ 1

Help required in removing error from this code?

https://code.sololearn.com/WS3x41OFM42G/?ref=app In the above code, there is an error arising in JS section. I don't know why because I wrote this on my pc and have run it numerous times but I am unable to understand why it's giving an error here. Also, help me in adding some modification so that it can completely fit in the sololearn output section. Thanks in advance.

21st Aug 2017, 12:30 PM
Alankar Mahajan
Alankar Mahajan - avatar
10 Antworten
+ 7
Set Javascript codes called by onload function: window.onload = function() { // put JavaScript code here } https://code.sololearn.com/W2NN0Ta95gm7/?ref=app
21st Aug 2017, 12:39 PM
Calviղ
Calviղ - avatar
+ 2
window.onload set an event , and call the function when the window is completely load. You can also do : window.addEventListener("load",function () {//javascript code here })
21st Aug 2017, 3:19 PM
Telo Philippe
Telo Philippe - avatar
+ 1
sololearn put your js in head tag and it run before body content loaded, so , like @Calvin posted, you need to tell "browser" to run your js after your page fully loaded
21st Aug 2017, 1:09 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
+ 1
in the js tab, add "window.onload = function ( ) { " at the first line, and "}" at the last line
21st Aug 2017, 2:45 PM
Telo Philippe
Telo Philippe - avatar
+ 1
and your game is very cool when it work
21st Aug 2017, 2:47 PM
Telo Philippe
Telo Philippe - avatar
+ 1
@Telo Philippe Thanks. I have just entered the world of web development. This game was a project I was given while learning a course. More of a code along project.. but I first tried myself and then saw the solution whenever I got stuck.
21st Aug 2017, 3:10 PM
Alankar Mahajan
Alankar Mahajan - avatar
+ 1
Thanks guys for your help..but as i mentioned above I need some way to set the game to fit according to mobile screen in output section..the width I tried is not working.
21st Aug 2017, 3:10 PM
Alankar Mahajan
Alankar Mahajan - avatar
+ 1
And also can you tell me the reason of using window.onload()?
21st Aug 2017, 3:14 PM
Alankar Mahajan
Alankar Mahajan - avatar
+ 1
in css remove min-width for body
21st Aug 2017, 3:22 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
0
Thank you guys.. everything's cool now.. I have made the game public..Enjoy!
21st Aug 2017, 3:34 PM
Alankar Mahajan
Alankar Mahajan - avatar