Web Designer? Design and market your own professional website with easy-to-use tools.
Functions are declared with the "function" keyword followed by the function name. Paranthesis immediately follow the function name. The paranthesis contain the parameters of the function.
For example, the statement, function popup() declares a function named popup.
A function can be called from anywhere within the <head> and <body> sections of a document, however, it is best to put functions in the <head> section so that they are read/loaded by the web browser before they are called.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<input type="button" onclick="popup()" value="Call function" />
Pressing the button below will call the function "popup".