+ 3
How can I organise my javascript?
The javascript that I include in my Web page doesn't works mod of the time
10 Réponses
+ 4
Comment your javascript file code because it will make you easier to understand and organise
+ 3
I include javascript in sololearn in JS sololearn playground.
+ 2
Please elaborate it more.
+ 2
Usually I include javascript in web page linked through <script src = "url.js"><\script> i.e. localy stored in my device
+ 2
Ruby Kumari I wrote: "in the html tab [ ... ] at the place wich fit to you"... Doesn't make it obvious that could be "in body or head tags" ^^ ?
+ 1
It may be a mistake in linking javascript files to html. It will be good if specify. This problem is on sololearn playground or on your local machine.
If you show your attempts. It will be easier for us to answer the question
+ 1
You can create another javascript file rather than including in html (body tag) page.
Use:
<script src = "name.js"></script>
In your HTML page.
+ 1
You can add your javascript codes in body or head tags
0
We need accurate informations to be able to help you:
In wich context do you run your web page?
If your code run in sololearn code playground, it doesn't work as you could think, for different reasons...
How do you include the javascript in your web page?
1) in the sololearn code playground JS tab
2) wrapped in a <script></script> pair tag
3) linked through a <script src="url/to/script.js"></script> empty pair tag (if so, in wich context? sololearn code playground, localy on your device, internet hosting service, what is the 'src' value you set and where is located your script file?)
0
In sololearn code playground context you cannot link external files located on your device ^^
You need to include your JS either in the JS tab (as if it was in a <script></script> at the end of the <head> part of the html tab) or in the html tab, wrapped in a <script> (without src attribute, otherwise that woud cause the js to be ignored), at the place wich fit to you (scripts inserted in the <head> section are executed before DOM ready, so you need to defer execution of code attempting to access the DOM to either an on 'load' or on 'DOMContentLoaded' events ;P)...