Showing posts with label EXTERNAL FILE. Show all posts
Showing posts with label EXTERNAL FILE. Show all posts

Monday, May 3, 2021

RUNNING EXTERNAL FILES IN JAVASCRIPTS


GLSW4E BOOKS FACEBOOK  W4E INSTAGRAM W4E YOUTUBEW4E HOME
FOLLOW US


In this sections, we will learn how to run a script (as an external file) from another JavaScript file. 


Before we start, let us see more examples on adding script to html:

RUNNING EXTERNAL FILES IN JAVASCRIPTS-GLS


Another example

RUNNING EXTERNAL FILES IN JAVASCRIPTS--GLS


Now lets see how we can run a script from another html/JavaScript file.


--------Create external JavaScript file with the extension .js.

--------After creating, add it to the HTML file in the script tag.

--------The src attribute is used to include that external JavaScript file.

---------If you have more than one external JavaScript file, then add it in the same web page to increase performance of the page.

•Example:

•Let’s say you created the following new.js external JavaScript file:

RUNNING EXTERNAL FILES IN JAVASCRIPTS

 Now add the external JavaScript file to the HTML web page:

RUNNING EXTERNAL FILES IN JAVASCRIPTS


So that is how to call one script from another. Next, we will look at the types of DATA YPES that are supported n JavaScript.


CONTINUE READING - SUPPORTED DATA TYPES IN JAVASCRIPTS


Watch Video

 

Sunday, May 2, 2021

SIMPLE JAVASCRIPT PROGRAMS

 

GLSW4E BOOKS FACEBOOK  W4E INSTAGRAM W4E YOUTUBEW4E HOME
FOLLOW US

*****Basic Structure of a JavaScript/Html program*****

Every JavaScript program takes the basic structure below, where we set all the html tags. Notice that the script tag is placed inside the body of the html (this can also be placed in the head). Also notice the other html elements in the body part of the program, those are the elements that are displayed on the web page.

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title> INTRODUCTION TO JAVASCRIPT</title>

 </head>

<body>

        <img id="source_image" alt=".." />Original Image

           <input type='button' id='change' value="changecolor" />

           <input type='button' id='result' value="get_Result" onclick=""/>

             

            <script>

            </script>

</body>

</html>


----Basic structure of html components

 

 SIMPLE JAVASCRIPT PROGRAMS

 

To create your first code:

----Open you desired text editor (Notepad++ in our example)

 SIMPLE JAVASCRIPT PROGRAMS


-----Add all HTML tags and elements. 

 SIMPLE JAVASCRIPT PROGRAMS--GLS

 

-----Add a script tag to the HTML head or body. 

 SIMPLE JAVASCRIPT PROGRAMS--GLS
 

  To do so, insert a 

<script language="JavaScript"> tag 

in the head or in the body.

 

This tells the text editor that you'd like to use JavaScript language to write your HTML JavaScript “program”.

                 

Add the script tag: If you want the script to automatically run when the site loads, don't include a function. If you want to call your script (maybe using a button or label), then include a function.

-----•Call up Another JavaScript scripts using a JavaScript function. 


SIMPLE JAVASCRIPT PROGRAMS--GLS


   You can also call another script If you know where the script file can be found, add a src= property to the script tag and include the complete web address or file path for the JavaScript file.

•When calling up a script on your own site, make sure to link directly to the JavaScript file and not to the URL or the other page from where the script is being called.

<script type="text/JavaScript" src = “Point" > </script>

-----Save the html file (using any file name with .html extension)

 

-----Run it by double clicking on the file name at the file location

 

CCONTINUE READING - RUNNING EXTERNAL FILES

Watch Video


 

MORE JAVASCRIPT ARTICLES FROM GLS BELOW