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
|