+ 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?

6th Jan 2020, 5:45 AM
InfinityAJ
InfinityAJ - avatar
10 Respuestas
+ 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
7th Jan 2020, 5:36 AM
Gordon
Gordon - avatar
+ 9
To implement the amendment, you need to understand a JavaScript concept called Closure. https://www.sololearn.com/post/45261/?ref=app
7th Jan 2020, 5:48 AM
Gordon
Gordon - avatar
+ 8
Share your code so that you can get exact solution
7th Jan 2020, 5:29 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 6
https://stackoverflow.com/questions/32711097/location-reload-giving-error?r=SearchResults Check this,,, I think it helpful i am not sure🤷‍♂️
7th Jan 2020, 4:59 AM
🇮🇳Abhay Pratap Singh🇮🇳
🇮🇳Abhay Pratap Singh🇮🇳 - avatar
+ 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.
7th Jan 2020, 5:43 AM
A͢J
A͢J - avatar
+ 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.
7th Jan 2020, 5:45 AM
InfinityAJ
InfinityAJ - avatar
+ 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/
7th Jan 2020, 7:17 AM
David Carroll
David Carroll - avatar
7th Jan 2020, 4:45 AM
Hafsa Mohamed
Hafsa Mohamed - avatar
+ 4
Abhay Pratap Singh thanks But it doesn't help because problem occurs in sololearn. In browser, it works just fine.
7th Jan 2020, 5:05 AM
InfinityAJ
InfinityAJ - avatar
+ 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.
7th Jan 2020, 5:39 AM
InfinityAJ
InfinityAJ - avatar