+ 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.
10 Réponses
+ 7
Set Javascript codes called by onload function:
window.onload = function() {
// put JavaScript code here
}
https://code.sololearn.com/W2NN0Ta95gm7/?ref=app
+ 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 })
+ 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
+ 1
in the js tab, add "window.onload = function ( ) { " at the first line, and "}" at the last line
+ 1
and your game is very cool when it work
+ 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.
+ 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.
+ 1
And also can you tell me the reason of using window.onload()?
+ 1
in css remove min-width for body
0
Thank you guys.. everything's cool now.. I have made the game public..Enjoy!