Buy best selling Linux books

<< View More Computer Tips

Added On: 14/10/18   |    Category: Vanilla Javascript    |    Number of Views: 712

Javascript document.write(). Javascript for begineers   

If your going to use jquery, or some of the new javascript frameworks and never programmed with javascript before, it's a good idea to learn the basics first, or what they call today Vanilla Javascript.

Over the years I never spent enough time learning to programme in Javascript, and probably like a lot of other users found code online and modified it to fit my needs. That always left me feeling annoyed as it didn't give me a proper understand of the how the script worked, and if I wanted to take the script further I couldn't do it.

I have set myself a challenge to learn some Javascript. I will be adding some examples with explanations for my own reference on the site, and hope that it will come in useful to other users wishing to learn Javascript.

Where to start
One thing I love about Javascript is the ability to write scripts using just a plain text editor, and test it locally in your web browser without the need to upload it to a server, like you would with server side languages such as .php.

Creating a simple javascript is simple, which brings me to the first example, using the document.write() command to out a simple message to your screen.

Example 1: Using document.write() command in Javascript
Create a new .html document on your desktop, and rename the file example1.html

Open the document in your text editor and copy and paste the following code.

<script>
document.write("My Computer Tips");
</script>


Save the document and open it in your webbrowser. My Computer Tips will be printed to the screen.

Example 1: Using document write() in javascript
Example 2: Using document.getElementByID() in javascript to send form data
Example 3: Generate a random number between 1 and 5 using Math.floor and Math.random commands in Javascript

Search Site

Search other tutorials and tips on My Computer Tips by entering your search terms below

Services

The Linux Foundation

Best selling Unix / Linux books
Nvidia Graphics Cards
Save 15% off .CO.UK domains at 123-Reg
Save 15% off .COM domains at 123-Reg
cPanel Hosting Plans
Xilo Web Hosting Plans