• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript What is JavaScript?

Malcolm

Administrator
Administrator
Staff Team
What is JavaScript?
JavaScript is exactly what the name says; it’s a script that controls the behaviour of a website. It helps make your website more interactable and there is no need for any special IDE platforms, you can create it using a regular text editor. In this thread, you will be given a quick understanding on how JavaScript works with HTML+CSS, add JavaScript (JS) within your HTML document, and how to link it externally to a .JS file.

How does JavaScript work with HTML+CSS?
Similar to both HTML and CSS, JavaScript has its purpose. In other threads, I explained what both HTML and CSS were and their purpose. Just a refresher: HTML is the structure of a webpage and CSS is used to style the appearance of the webpage.
Now, what does JavaScript do? JavaScript makes your basic HTML/CSS document or webpage more interactive. It can be used to update content, animate images, control multimedia, display prompts etc. It can give the viewer warnings stating that their password does not meet requirements, or give a specific message like good morning or good afternoon. JavaScript can make your site do a lot of great things, you just need to conquer it. Remember JavaScript is a scripting language so you set a set of instructions and the browser will execute them.

Adding JavaScript within your HTML Document:
Although not particularly recommended, you can add JavaScript within your HTML document by using the <script></script> tag. An example is below:
HTML: Internal JavaScript:
<!DOCTYPE html>
    <head></head>
    <body>
    <h1>Hello World!</h1>
        <script>
            document.write(‘Hello World!’); // Will print off “Hello World!”
        </script>
    <body>
</html>

Adding JavaScript with an external document:
A more practical way of adding JavaScript to your website is by creating a separate JavaScript file and linking it to your HTML document. Similar to the way of including an external CSS file. You can identify a JavaScript file by looking for the file extension .js.​
Within your HTML document under the <head> tag:​
HTML: External JavaScript:
<head>
    <script src=”js/javascript.js”></script>
</head>

The src attribute is the file path to your .js file.

Helpful sources:
JavaScript & Jquery by Jon Duckett
 
Last edited:
D

Dan-Kode

Guest
Just to add as a Note, JavaScript is not Java. They are both completely different Languages for completely different Tasks.

JavaScript is used for Websites, adding Functionality to them and making them more Dynamic.

Java on the other hand is used for Banks, Software and Android Apps.

Always remember that both Languages are completely different in terms of Functionality, Tasks and Syntax, despite the Name.
 

Malcolm

Administrator
Administrator
Staff Team
Just to add as a Note, JavaScript is not Java. They are both completely different Languages for completely different Tasks.

JavaScript is used for Websites, adding Functionality to them and making them more Dynamic.

Java on the other hand is used for Banks, Software and Android Apps.

Always remember that both Languages are completely different in terms of Functionality, Tasks and Syntax, despite the Name.
Thanks for pointing this out! :)
 

Top