- Browser Application Programming Interfaces ( APIs ) – APIs built within browsers that offer functionality such as dynamically creating HTML content and setting CSS styles to capturing and manipulating a video from the user’s webcam, or generating 3D graphics and samples of sound.
- Third-party libraries and frameworks that you can apply to your HTML so you can quickly build and publish sites and applications.
Below are some features of the core of the language. You will also play with a few features of the browser API. Have fun!
Example, ” Hello World! »
It allows for speed and immediacy that is impossible in other languages such as PHP that run on the webserver.
✔ Inserted inside <script> </script> tags
Some examples below:
The alert () function opens a small alert box in the browser, displaying whatever information you specify.
If we insert it directly into a script element in the following way, it will be executed immediately when the page is loaded.
<script> alert('Message'); </script>
To use it only at the reader’s request, we must use it within another function, which we call in this example “in alert”, which we will call using a link in the following way.
Another even easier way to do it is to include the function directly in a link, as follows:
The same function can also be inserted into different elements using the “onclick” event as a trigger.
Two examples, in a button and in a block or container.
This method is only useful for simple functions; however, it helps us experiment.
Then instead of a text message, we get the title of this page using the “document.title” object.
Try: See title
location.href – Displays the URL of this page.
navigator.appName – Displays the name of the browser.
document.cookie – Sample cookies saved by this site.
document.lastModified – Shows the exact date and time this document was last modified.
On web pages, it is used mainly for the following tasks:
1- Facilitate the reader to interact with the page’s content through events in buttons, links, blocks, and any other element.
Actions such as scrolling the page, hovering the mouse over any item, executing keystrokes, etc. can also be detected. And based on that, execute certain actions.
It adds dynamism and makes the internet pages more functional.
2- Send or transfer data from the server on the internet without reloading the page using AJAX.
For example, write updates on social networks and receive notifications in real-time, use chat, send and receive messages, upload content from other pages or RSS files, etc.
3- Manipulate the structure of the pages (DOM).
Its functions and methods allow you to modify blocks or isolated elements, delete them, move them, change their style, or add content to them, among other functionalities.
4- Convert the pages into web applications. It is possible to play games, listen to music or video, edit images and other actions, similarly as we do with programs on the computer.