Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

JavaScript

Apprentices:
Peña Emiro
Rentería Yonathan
Suarez Fabian
Elkin Velasques
What is it?

JavaScript is a programming or scripting language that allows you to

implement complex functions in web pages, every time a web page does more

than sit there and display static information for you to see, it displays

timely content updates, interactive maps , 2D / 3D graphics animation, video

player scrolling, etc., you can bet that JavaScript is probably involved.
So what can you really do?

• The core of the client-side JavaScript language consists of some


common programming features that allow you to do things like:
• Store useful values ​within variables. In the example above, for
example, we asked you to enter a new name and then we stored that
name in a variable called name.
• Operations on text fragments (known as "strings" in programming). In
the example above, we took the string "Player1:" and attached it to the
name variable to create the complete text label, eg. ex. '' Player1:
Chris ".
• And it executes code in response to certain events that occur on a web
page. We used a click event in our previous example to detect when the
button is clicked and then run the code that updates the text label.
Safety

JavaScript and the DOM allow programmers who make inappropriate


use to introduce scripts that execute code with malicious content
without the consent of the user and that could thus compromise their
security.
Browser developers take this risk into account using two restrictions.
First, the scripts are run in a sandbox where only web-related actions
can be performed, not general-purpose programming tasks such as file
creation. Second, it is limited by the same origin policy: scripts on one
website do not have access to information sent to another website
(from another domain) such as usernames, passwords or cookies. Most
JavaScript security flaws are related to violations of either of these
two restrictions.
Most important labels

• // code to explain // the swihct case is used to find the correct


option within several. var text; var = prompt (""); switch () {case
"": alert (""); break; default: alert ("");}

• // conditions with yes and no, if () {alert ("")} else {alert ("")}

• line breaks \ n </br>


Label Examples

• Display a welcome message on the screen

• Example 1 . Display a welcome message to the web page on the


screen.
Label Examples

• In our first example, we will simply create a Javascript that will display a
welcome message when the user enters the Web page. Increasingly, Web
pages display such a welcoming message when they are entered.

• As you can see, the Javascript code is placed (or embedded) within one
of HTML, enclosing it between the <script> </script> tags.

• Open Notepad, copy the code above and save it as Example01.html. (If
you don't feel like doing this you can open it from the Examples I
directory). Then run it by double-clicking the mouse.
Label Examples

• Back button

• Example 2. Button that when pressed returns to the previous page of


the one that existed at that moment.
• It is a button to go back, similar to the one we have in the browser
toolbar. Pressing the button performs a Javascript instruction.
Label Examples

• This Javascript instruction, called history.go (-1), is inside an


HTML attribute, onclick, which indicates that this instruction
will ONLY be executed when the button is pressed, represented
by the HTML INPUT tag. A bit more technical, the event is to
press the button (onclick) and the action (history.go (-1)) is to
return to the previous page in the browsing history. To see it
correctly, first run Example01.html! (Example02 needs some
page to go back).
Label Examples

• Collect data by keyboard and view it

• Example 3. Displays the name entered by keyboard on the screen

• On many occasions it will be very useful to collect data from the keyboard and save it to later
make decisions according to what has been entered (very useful, for example, for user access to
the pages). In this example, the variable that we define, nom, will help us to save what we enter
on the keyboard through the Javascript prompt function.
Thank you!!!

Most of the people think that the


design is a veneer, it is a simple
decoration. For me, nothing is more
important in the future than
design. Design is the soul of
everything created by man

Steve Jobs

You might also like