Home | Add to Favorites | Ebooks Directory | News  
Javascript   Resources
Home
Javascript  Article
JavaScript Tutorial 
Java Script Example
Books
JavaScript  Download
Java script Reference
JavaScript Tutorial
 

Example 4

Confirmation boxes have OK and Cancel buttons whereas Alert boxes have OK button only. On clicking OK, the confirmation box returns true whereas on clicking Cancel button, it returns
false.


 

html>
<body>
<script language="javascript">
var flag=confirm("hello World");
if(flag)
{
document.write("U clicked OK");
}
else
{
document.write("U clicked Cancel");
}
</script>
</body>
</html>


 

Example 5

Prompt box has OK,cancel buttons and a text box to take input from the user
The script here takes the input from the prompt and displays it in the browser.
The prompt box method returns the input string taken in the input Box.

 

<html>
<body>
<script language="javascript">
var input=prompt("Enter your name:");
document.write("My name is "+input);
</script>
</body>
</html>


Example 6

The browser name and its version on which the script is run can be found out as follows.
The navigator objects' appName (application name) property gives the Browser software used and the
the appVersion (application version) property gives the version of the browser used.

<html>
<body>
<script language="javascript">
document.write("Browser: "+navigator.appName+"<br>Browser version: "+navigator.appVersion);
</script>
</body>
</html>

An Event is some happening and javascript has event handlers to handle such events.
The script can be executed when a specific event occurs.
some of the eventhandlers are onClick,onBlur,onKeypress,onKeydown,onKeyup,onMouseover,onMouseout,onChange,etc,..

                                                            Go To Index