Learn HTML,CSS, Python etc from the foundation

Tuesday, February 5, 2019

PRACTICAL GUIDE ON HOW TO WRITE YOUR FIRST JAVASCRIPT PROGRAM

1 comment :


Hi, in this masterpiece, I will try my best to guide you on how to successfully write your first Javascript program without stress.  As you may have discovered in our first introductory lesson, that you don’t need any special software installation or IDE in order to run or test your JavaScript programs. All the tools we are going to need here are almost the same as what we used for CSS and  HTML course.  
In order words, you will still use either, sublime text, Dreamweaver, VS code, DroidEdit (best for Android phones), notepad++, coda, etc. You must not download all, one is enough depending on your choice. For me, I’ve chosen Sublime text.
There are things I think you should know before you can successfully write your first JavaScript program. Firstly, I want you to take a close but critical look at the JavaScript basic template.

JAVASCRIPT BASIC TEMPLATE
<!DOCTYPE HTML>
         <HTML>
         <HEAD>
            <TITLE>JS TEMPLATE</TITLE>
        </HEAD>
            <BODY>
                <SCRIPT LANGUAGE = “Javascript”>
                        </SCRIPT>
            </BODY>
    </HTML>

EXPLANATION
Notice how we placed our  <SCRIPT> tags in between the <BODY> opening tag and </BODY>  closing tags. You can still place your <SCRIPT> tags externally or in  <HEAD> section, but it has to be parsed  ( ASIDE: Never worry if you don’t understand, I have designed a special topic for JavaScript placements, you will understand better when we get there.). 
However, note the following codes between the body tags:
                <SCRIPT LANGUAGE = “Javascript”>
                        </SCRIPT>
These codes are used to embed JavaScript codes into the HTML document.  JavaScript is a scripting language. So ‘’SCRIPT LANGUAGE =’’ is used to indicate the kind of scripting language you want to use. Just like DOCTYPE in HTML,  which stands for document type, is used to introduce our HTML document.
Below this line <SCRIPT LANGUAGE = “Javascript”>  is where you input your JavaScript codes. Do not forget to surround the word Javascript with double quotes, else you will get a blank page. However, It is not compulsory you include this line  ‘’<SCRIPT LANGUAGE = “Javascript”>’’. You can actually put it this way:

<!DOCTYPE HTML>
         <HTML>
         <HEAD>
            <TITLE>JS TEMPLATE</TITLE>
        </HEAD>
            <BODY>
                      <SCRIPT >
                   …………………….
                        </SCRIPT>
            </BODY>
    </HTML>

Then write your codes between <SCRIPT> </SCRIPT> tags.   Let us now write our first JavaScript Program

OUR FIRST JAVASCRIPT PROGRAM
Open your text editor and write the following piece of codes
<!DOCTYPE HTML>
         <HTML>
         <HEAD>
            <TITLE>OUR FIRST PROGRAM</TITLE>
        </HEAD>
            <BODY>
                <SCRIPT LANGUAGE = “Javascript”>
                       alert(“Hello World”)
                        </SCRIPT>
            </BODY>
    </HTML>
NOTE
You can write all the above codes with either uppercase or lowercase except JavaScript codes which must be in lowercase. For example ‘alert’ can never be ‘’Alert or ALERT’’. Also, take note of the round brackets and double quotation marks. Miss any of these and your web browser will display a blank page.
 THE CODES ABOVE WILL LOOK LIKE THIS IN YOUR TEXT EDITOR



SAVE AND OPEN IT WITH INTERNET EXPLORER OR ANY OTHER WEB BROWSER
(IT LOOKS LIKE THIS ON INTERNET EXPLORER THOUGH)



WRAPPING UP

I believe you can now successfully write your first JavaScript program and run it without tears. In our next lesson, will be considering  ‘’Confirm and Prompt box’’

1 comment :

  1. Hotel Casino, BW Hotel Casino, BW Hotel, BW Hotel, BW - Mapyro
    Hotel Casino, BW Hotel, 여수 출장마사지 BW Hotel, 정읍 출장샵 BW Hotel, BW Hotel, BW Hotel, 김제 출장안마 BW 광양 출장마사지 Hotel, BW Hotel, BW Hotel, BW Hotel, BW Hotel, BW Hotel, BW Hotel, BW 삼척 출장샵 Hotel, BW

    ReplyDelete