+ 1

Redirect from the SoloLearn application to the browser. How to do it in the right way?

My Android System Webview does not support ES6 and WebGL and the sandbox in the application cannot display the results. I would like to redirect to the default browser or any browser installed on the system in case of an error, such as the inability to get the webgl context from the canvas. Now my solution is to set the window.location.href attribute to the url value (obtained by clicking the share button in the sandbox) and change the document body by writing a string informing about the lack of webgl support and then stop executing the script. But if the document body is changed immediately Before the completion of the script, the redirect will not occur, so the body needs to be changed after a while. I am doing this workaround: setTimeout (function () {document.write("webgl is unsupported!");}, 1000); Below you can see how it works. https://code.sololearn.com/W8zPB0KdcBl9/?ref=app Maybe I am doing the redirect wrong. What is the best way to do this?

5th Apr 2019, 1:40 AM
Svetlana V
Svetlana V - avatar
2 odpowiedzi
+ 5
Try this it will ask the user to choose to open this in browser or SoloLearn but if SoloLearn is set to default it will be again will opened in SoloLearn. if (confirm("WebGL is unsupported! :(\n\nTry to show it in another web browser?")) { // trying to open web browser... // ADD THIS document.write("<button onclick='window.open(thisLink)'>Open</button>"); }
5th Apr 2019, 7:49 AM
VEDANG
VEDANG - avatar
+ 1
Thanks.
5th Apr 2019, 12:35 PM
Svetlana V
Svetlana V - avatar