HTML and CSS Reference
In-Depth Information
example 5.3: Creating and assigning actions to buttons
<!DOCTYPE html>
<title>Example 5.3</title>
<script type="text/javascript">
/* Provide an array of destinations */
links = [ '',
'' ];
/* simple function to link to a random URL */
function goToRandomURL() {
var x = Math.floor(links.length * (Math.random() % 1));
location = links[x];
<body style="padding: 36px;">
<div style="text-align: center;">
<button id="btn1" onclick="location = this.value;"
value="about.html"> More Info </button>
<button id="btn2" onclick="goToRandomURL();"
value=""> Random Search Engine </button>
<button id="btn3" onclick="self.close();"
disabled="disabled" value="exit.html"> Go Away! </button>
Figure 5.3 shows how the buttons are rendered in a typical browser.
Search WWH ::

Custom Search