Friday, March 13, 2015

Testing Java Script, setting environment for Java Script

While starting to develop a JavaScript or writting codes and programs in JavaScript, a good working environment with atleast basic knowledge about JavaScript is required. JavaScript is written in a code editor/notepad etc. 

It can be written in a normal text editor or you can use software/I.D.E like Dream Weaver, PHP Storm, Eclipse, Net Beans, etc. The editor should have syntax highlighting and auto complete features for making your coding easier and convenient if you are a starter. 


As browser is the most and the developer tools provided by them plays a vital role while working with JavaScript, many popular browsers like Mozilla Firefox, Google Chrome, Internet Explorer, etc. support JavaScript and have developer tools in them but they may differ in every browser. 

Following are the steps to put JavaScript file according as your requirement in document.

Step1

Open the editor on your machine editor can be notepad, Eclips, PHP Strom or whichever IDE you have with you .

Step2

Write the code of JavaScript internally or externally that can be including within HTML Document like as follows within <script> and  </script> tag.
 <script>  
     function changeImage() {  
 varimg = document.getElementById('image');  
       if (img.src.match("logo")) {  
 img.src = "funny.png";  
       } else {  
 img.src = "ft_logo.jpg";  
       }  
     }  
 </script> 

Step3

Save the file in particular directory or drive with appropriate extension.

Step4


Open the saved file with one of your Browser to see the effect of JavaScript. [recommended Google Chrome]



Now while talking about development tools provided by browsers, there are many options that helps debug,test and utilize your coding. We shall follow up those materials in another post.

No comments:

Post a Comment