Monday, October 26, 2009

Using the Switch Statement


The Switch Statement is a sort of Conditional, it tests for instances of something, usually a variable value.

 


Here the function displayAlert assigns a value to the variable OSName by way of a prompt box:
 

Edit code, then select and copy:  
Command-A/command-C to copy (Mac) | alt-A/alt-C (Windows)

Here the function displayAlert is called by clicking on an image in the main body of the page:
 
<a href="http://www.yourDomain.com/" onclick="displayAlert()"><img src="http://www.yourDomain.com/yourImage.jpg"/></a> </body> </html>

Or you could create a button, 'Switch Activate' in this case, to do the job:

<button type="button" name="Switch Activate" onclick="displayAlert()"></button>
 

Want HTML Code? Go to: http://write-html-code.blogspot.com/
 
Learning How to Write JavaScript Code' to Technorati Favorites

No comments:

Post a Comment