Computer Skills for Research

Scripting in JavaScript

By

First published on February 27, 2019


Javascript is a scripting language that is executed in web pages. Javascript is responsible for much of the interactivity you encounter in webpages. Javascript can manipulate many of the objects in a web page.  Javascript can be included directly in html files, or it can be in its own file and referenced by the html file.

Let’s explore a simple script included in an html page. Below is some HTML code for a button, followed by some Javascript code. Clicking the button will pop up an alert window displaying “Hello!”

<button onclick="myPopupBox()">Click here</button>   

<script> 
    function myPopupBox() { alert("Hello!");} 
</script>

Javascript can use variables and functions, so it behaves much as other programming languages. Generally, Javascript must be enclosed in script tags.

Javascript can write to an alert window, to a web page, or to specific elements in a web page.

Resource


| COURSE |


Content is copyright the author. Layout is copyright Corsbook. See Corsbook.com for further notices.