Let’s write a piece of script and for doing that we first make HTML file (web page). Open your code editor and Create new file with .html extension (i.e jstoast.html). If you are new to coding and web development, I highly recommend you to take a look on another toast about setting up your environment for start web development using Sublime Text Editor.

Create an html document

</pre>
<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Alert Function</title>

</head>

<body>

&nbsp;

&nbsp;

</body>

</html>
<pre>

All of your script would be placed between SCRIPT element to somehow tells the browser that we are going to write JavaScript and we want you to bear it

 

 

</pre>
<body>

<script>

</script>

&nbsp;

</body>
<pre>

 

Now we are going to write our first line of JavaScript code and I can feel your excitement.

<script>

alert();

</script>

We simply call a built in function named ‘ALERT’. A function is a command that does something specific. ALERT function opens a pop up window in browser. Please note that we place a semi-colon at the end of the line which is must.

We will write the information in that ‘ALERT’ function that we want to specify in that pop up window.


alert("Hi there");

Please note that the information is close in parenthesis ( “ “) . This will write “Hi There” in the pop up window. Try that


<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Alert Function</title>

</head>

<body>

<script>

alert("Hi There");

</script>

&nbsp;

</body>

</html>