4 Books in 1. A Complete Beginners Guide To Learn The Fundamentals of JavaScript, Python, SQL & Java.
The content contained within this book may not be reproduced, duplicated or transmitted without direct written permission from the author or the publisher. Under no circumstances will any blame or legal responsibility be held against the publisher, or author, for any damages, reparation, or monetary loss due the information contained within this book. Either directly or indirectly.
This book is copyright protected. This book is only for personal use. You cannot amend, distribute, sell, use, quote or paraphrase any part, or the content within this book, without the consent of the author or publisher.
JAVASCRIPT FOR
BEGINNERS:
The Complete Modern Guide To Start Learn Quickly And Easily Javascript Language. Coding And Program With Tips And Tricks
Introduction
There are plenty of books on this subject on the market, thanks again for choosing this one! Every effort was made to ensure it is full of as much useful information as possible, please enjoy!
What is JavaScript?
JavaScript is an interpreted programming language, so it is not necessary to compile the programs to execute them. In other words, programs written with JavaScript can be tested directly in any browser without the need for intermediate processes.
Despite its name, JavaScript has no direct relationship with the Java programming language.
How to include JavaScript in XHTML documents
The integration of JavaScript and XHTML is very flexible since there are at least three ways to include JavaScript code in web pages.
Include JavaScript in the same XHTML document
The JavaScript code is enclosed between tags and is included anywhere in the document. Although it is correct to include any block of code in any area of the page, it is recommended to define the JavaScript code within the header of the document (within the tag).
Example of JavaScript code in the document itself
alert ("A test message");
A paragraph of text.
In order for the resulting XHTML page to be valid, it is necessary to add the type attribute to the < script>. The values included in the type attribute are standardized and in the case of JavaScript, the correct value is text / javascript.
This method is used when defining a small block of code or when you want to include specific instructions in a specific HTML document that complete the instructions and functions that are included by default in all documents on the website.
The main drawback is that if you want to make a modification to the code block, it is necessary to modify all the pages that include that same block of JavaScript code.
Define JavaScript in an external file
JavaScript instructions can be included in an external JavaScript file that XHTML documents link using the tag. You can create all the necessary JavaScript files and each XHTML document can link as many JavaScript files as you need.
In addition to the type attribute, this method requires defining the src attribute, which indicates the URL corresponding to the JavaScript file to be linked. Each tag can only link a single file, but on the same page you can include as many tags as necessary.
JavaScript files are normal text documents with the extension .js, which can be created with any text editor such as Notepad, Wordpad, EmEditor, UltraEdit, Vi, etc.
The main advantage of linking an external JavaScript file is that the XHTML code of the page is simplified, that the same JavaScript code can be reused on all pages of the website and that any modification made to the JavaScript file is immediately reflected in all the XHTML pages that link it.
Include JavaScript in XHTML elements
This last method is the least used, since it consists of including JavaScript pieces within the XHTML code of the page:
Example of JavaScript code in the document itself
A paragraph of text.
The biggest drawback of this method is that it unnecessarily soils the page's XHTML code and complicates maintenance of the JavaScript code. In general, this method is only used to define some events and in some other special cases, as will be seen later.
Noscript Tag
Some browsers do not have full JavaScript support, other browsers allow you to partially block it and even some users completely block the use of JavaScript because they believe they are browsing more securely.
In these cases, it is common that if the web page requires JavaScript for its correct operation, a warning message to the user is included indicating that you should activate JavaScript to fully enjoy the page. The following example shows a JavaScript-based web page when accessed with JavaScript enabled and when accessed with JavaScript completely disabled.
The following code shows an example of using the tag:
...
Welcome to My Site
The page you are viewing requires the use of JavaScript for its operation.
If you have intentionally disabled it, please enable it again.
The tag must be included inside the tag (usually included at the beginning of ). The message that shows can include any XHTML element or tag.
Basic Glossary
Script: each of the programs, applications or pieces of code created with the JavaScript programming language. A few lines of code form a script and a file of thousands of lines of JavaScript is also considered a script. Sometimes it is translated into Spanish directly as "escribir", although script is a more appropriate and commonly accepted word.