+ 1

How can I run javascript after background image of body has fully loaded?

29th Nov 2020, 5:44 AM
Jeremy Cruz
Jeremy Cruz - avatar
8 odpowiedzi
29th Nov 2020, 6:01 AM
Jeremy Cruz
Jeremy Cruz - avatar
+ 1
Your console was returning an error , await is only valid in async function. Rectify your code to: window.onload = async function(){ var url = await fetch(//your codes.....) }
29th Nov 2020, 6:25 AM
Devotha Mwenda
Devotha Mwenda - avatar
0
Not sure if this answers your question but try: window.onload = function(){ /*the code that you want to run after the whole page is fully loaded*/ }
29th Nov 2020, 5:50 AM
Devotha Mwenda
Devotha Mwenda - avatar
0
I did that, but it never ran the script.
29th Nov 2020, 5:55 AM
Jeremy Cruz
Jeremy Cruz - avatar
0
If you have your code in sololearn, please attach the link, this will be helpful in figuring out whats wrong.
29th Nov 2020, 5:58 AM
Devotha Mwenda
Devotha Mwenda - avatar
0
ok, but it’s still running the script without fully loading the background image.
29th Nov 2020, 6:27 AM
Jeremy Cruz
Jeremy Cruz - avatar
0
Lets wait for others responses! Stuck too!
29th Nov 2020, 6:53 AM
Devotha Mwenda
Devotha Mwenda - avatar
0
thanks for the help!
29th Nov 2020, 6:56 AM
Jeremy Cruz
Jeremy Cruz - avatar