ISMA309


javascript

Event handlers
An event handler can be considered a trigger that executes code when something happens, in the ‘event’ of a click or move your mouse over a link, submit a form etc. onClick onClick handlers execute something only when users click on buttons, links, etc. Let’s see an example: <html> <script> function specialsauce() { alert("Thank you!") […] Read more – ‘Event handlers’.
Functions
Prose is structured in sentences and paragraphs in the english language. In Javascript we structure our code in lines of instruction and functions. To create javascript that is easy to understand and maintain the code must be broken into smaller modules. These modules or packages of instructions are called functions and can be called upon […] Read more – ‘Functions’.
Variables and Conditions
Let’s first look at an example: <script type="text/javascript"> var x=window.confirm("Are you sure you want to quit") if (x) window.alert("Thank you.") else window.alert("Good choice.") </script> <script type="text/javascript"> var x=window.confirm("Are you sure you want to quit") if (x) window.alert("Thank you.") else window.alert("Good choice.") </script> There are several concepts that we should know. First of all, var x= […] Read more – ‘Variables and Conditions’.
Message Boxes
Message Boxes There are three message boxes: alert, confirm, and prompt. Alert Let’s look at the first one: <body> <script> window.alert("Welcome to my site!") </script> </body> <body> <script> window.alert("Welcome to my site!") </script> </body> You can put whatever you want inside the quotation marks. Confirm An example for confirm box: window.confirm("Are you sure you want […] Read more – ‘Message Boxes’.
Document Object Model
We can’t talk about JavaScript without mentioning the DOM, an important concept to understand about how javascript works. The Document Object Model or DOM provides a structural representation of an HTML or XML document, enabling us to modify its content and visual presentation. Essentially, it connects web pages to scripts or programming languages or alternately, […] Read more – ‘Document Object Model’.
Write and Writeln
In order to output text in JavaScript you must use write() or writeln(). Here’s an example: <HTML> <HEAD> <TITLE> Welcome to my site</TITLE> </HEAD> <BODY> <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- document.write("Welcome to my site!"); </SCRIPT> </BODY> </HTML> <HTML> <HEAD> <TITLE> Welcome to my site</TITLE> </HEAD> <BODY> <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- document.write("Welcome to my site!"); </SCRIPT> </BODY> </HTML> Note: […] Read more – ‘Write and Writeln’.
Javascript for Beginners
This is a quick introduction to Javascript for people new to programming. I’ve broken down the fundamentals of coding in Javascript into the following small chunks: Embedding and Including Javascript Write and Writeln Document Object Model Message Boxes Variables and Conditions Functions Event Handlers Read more – ‘Javascript for Beginners’.