+ 12
Location.reload doesn't work on sololearn
I am trying to add a button to restart the game. In my browser i can use this function "location.reload()" but it isn't working on sololearn. Any solution?
10 Answers
+ 14
no, sololearn code playground is not location, it is webview app with code compiled by server, so you can't use location.reload()
for restart feature, declare variables in global scope, add a restart button with event listener resetting these global variables.
https://code.sololearn.com/WrZat1vLX669/?ref=app
+ 9
To implement the amendment, you need to understand a JavaScript concept called Closure.
https://www.sololearn.com/post/45261/?ref=app
+ 8
Share your code so that you can get exact solution
+ 6
https://stackoverflow.com/questions/32711097/location-reload-giving-error?r=SearchResults
Check this,,,
I think it helpful i am not sure🤷♂️
+ 6
Anant Jain It's a simple thing. Sololearn is not a browser. It's a application which has terminal not browser. So some properties which works on browser will not work here.
For example if you are talking about location so location first check the URL of website but do you have URL in Sololearn app terminal? No. So it will not work here. But on browser to open any website we have URL or you can location of your website.
+ 6
🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ! Ya i know that i was just looking for some alternative function. Because now i have to make some major changes in my js. I was just trying to avoid that.
Thanks btw.
+ 5
Anant Jain I think the reason reload doesn't work is because the page is a special browser page with a URL of about:blank.
I suspect the content is injected into the DOM when the Run button is clicked.
When reloading the about:blank page, the content isn't injected on the reload.
See my test:
https://code.sololearn.com/WM6I243m70fP/
+ 4
Abhay Pratap Singh thanks
But it doesn't help because problem occurs in sololearn. In browser, it works just fine.
+ 3
Thanks Gordon i think that'll work
I knew that function won't work in app. I was hoping for some kind of alternative other than you told.
If it is the only option i will surely do it.