Creating and assigning actions to buttons : CSS Button « CSS Controls « HTML / CSS






Creating and assigning actions to buttons

  
<!DOCTYPE html> 
<html> 
<head> 
<title></title> 
<script type="text/javascript"> 
/* Provide an array of destinations */ 
links = [ 'http://yahoo.com', 
'http://google.com', 
'http://bing.com' ]; 
/* simple function to link to a random URL */ 
function goToRandomURL() { 
var x = Math.floor(links.length * (Math.random() % 1)); 
location = links[x]; 
return; 
} 
</script> 
</head> 
<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> 
</div> 
... 
</body> 
</html> 

   
    
  








Related examples in the same category

1.CSS Button with anchor
2.Shading Button
3.Read more and Comments buttons
4.Large Link button
5.Enlargable link button
6.Button navigation
7.A text button
8.Buttons
9.Buttons with button element
10.CSS Button
11.css rollover button
12.Using Image to create a Button
13.Button like right menu bar with mouse hover effect
14.Make anchor a button
15.Change input form button style