April 16th, 2014
Basic HTML/CSS knowledge recommended beyond this point! I probably should have started with an HTML tutorial… Also, I am adding on to this as I learn so keep checking back for more.
Before we get into variables there are a few things you should know.
1. Most of the time code errors are caused by missing quotes(single ‘ or double”) or missing colons at the end of each line( ; ).
2. I highly recommend you to use an HTML editor such as Dreamweaver (Note, Dreamweaver costs!) so you can see errors in your code, and easily upload files to ftp.
Making your first script.
All Java Scripts are either loaded directly in the pages source code, using <script> tags, or loaded externally(note that also uses <script> tags but in a different format).
For in-page loading(recommended if you are only going to be using your code for one page) you can begin as simply as this:
<script> var message='This is a script'; </script>
As with all html(with an exception for <input>) don’t forget to close it with a /. If you do it like <script><script> it won’t work correctly.
For external loading(if you want to use on multiple pages), you would do it like this:
<script src="https://your-site-or-ip.com/js/script.js" ></script>
Where “src” = your source for the file. Again, don’t forget the closing </script> tag.
When making a .js file, you don’t need to use <script> tags in it, that will just mess it up.
You can add comments to your code, if you want to remember things, or want to keep code, but not run it. You can add comments like so:
<script> var message = 'Why do people keep putting weird comments on these posts'; //seriously </script>
Comments Are Not Yet Implemented.