+ 2
Error
Who does this code work for? Source Code from Russ: https://code.sololearn.com/WtQTIVaw748j/?ref=app
23 odpowiedzi
+ 2
No, I was thinking that the code was saved by you in sololearn...
I don't know why the author say that his code run fine here (does he have really tested ?), because I use the code playground editor from years on both mobile devices and desktop, and the process had always be the same: the content of the js (and the css) tabs are dynamically inserted at the end of the <head> section of the html tab content before running... so, at this place, when the script is executed the DOM is not ready at all (you could access window and document objects, but you only could access the <head> part (not the <body> and its content, wich aren't be still read/parsed and DOM tree not already populated, appart code standing before the script tag): you need then to wait for the document load ends ;)
+ 3
So I am the creator of this code.
Just to clear up any confusion; yes, this code works perfectly fine on iOS - both on iPhone and on iPad. It also worked on a free, downloaded iOS IDE without any issues.
Thanks Vasiliy for flagging this up, though. I will always make sure I use the load event so that it should work for everyone 👍
+ 2
SoloLearn automatically loads the script in the <head> portion of the HTML file instead of at the end of the body. This is why you are getting a null error. The elements of the body don't exist when the script is loaded. So you need to use the onload wrapper so that loading of the script file is forced after the page loads. That way the structure and elements of the page exists when it is ran.
+ 2
Vasiliy
They're probably running it on their own machine and just copied the code here then. At least, that would be my guess.
+ 2
Thank you all, I satisfied my curiosity, otherwise I already began to doubt. 🙋
+ 2
Code Crasher
Please test this code:
https://code.sololearn.com/WtQTIVaw748j/?ref=app
Does it work for you?
+ 2
Code Crasher The iOS apps have always been well behind the Android app as far as I've been around here too (over two years). When new features came out, people were always talking about them and I had no idea what they were on about because they weren't accessible to iOS users until 3-6 months down the line. There was a point when coding challenges were allowed to be posted by people in the Q&A forum and doing those challenges was something a lot of us enjoyed. They stopped that because they brought in a new feature (Challenge Factory or something), but it was months before it was even availbale to iOS.
When SL brought in private messaging and we all had our own inboxes, by the time iOS had access to these PMs, I had messages around 6+ months old from people asking for help that I never knew about.
I have no idea why it appears to be so hard to create an app for iOS in the same time frame as it does for Android, or why the web Code Playground appears to act differently. It's a lot better than it was though!
+ 1
This code gives me an error, (line # 11).
And how are you?
This problem can be solved with the help of "onload=()=>{}"
+ 1
ChaoticDawg
I think so too, but the author of this code stated that he had no problems. 😕
+ 1
Probably the original author doesn't run his code in a sololearn playground project, and doesn't know how things works here ;)
If you don't want to wrap all the js tab in a onload function (clean way), you could cut / paste the whole content inside a <script> tag at the end of the <body> section of the html tab ^^
+ 1
visph, ChaoticDawg, do you do it from a smartphone?
Maybe he is engaged in SoloLearn with a "computer"? Although it is unlikely that the script will load differently 😕
+ 1
mobile device or desktop, that doesn't matter: in each case the process is the same ^^
+ 1
visph ☺️ I did not understand right away, do you mean that there is another author? 😃
+ 1
Code Crasher that's surprising, but probably the iOS app handle things differently :o
0
Code Crasher I would well believe the talent on here would be able to do the job but, at the end of the day, this is someone's business.
Whoever created SL did so apparently without income for a long time and have only fairly recently started monetising it through advertising and memberships. It would be entirely up to them what they do with it. While a competition sounds like a good idea, I think that would mean passing control of the business to users to an extent, and I can't see them really wanting to do that.
0
Code Crasher I see comments on lessons that are over 4 years old and they brought in ads and membership, I'd say, about 6-9 months ago.
I have no reason to suspect they are anywhere near going broke, just that after so much time and work, they felt they wanting to make something off the back of it. Can't blame them for a second.
0
In this case, the javascript section is running before the body tag. So,
You should put your whole javascript into the window.onload function like this:
window.onload = function () {
// Your javascript here
}