Closing Windows

By: aathishankaran Emailed: 1728 times Printed: 2329 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

To close a window, you can use the window object's close () method. If you are closing the current window, your method call is simply window.close (). Unlike other window object methods, such as alert () or setTimer (), the close () method must always accompany an object reference. If you use close () by itself, you could close the current document rather than the window, depending on the context of the method call. The reason is that the document object has a close () method, too. 

Displaying Message Boxes 

Dialog is one of the useful components in windows to display certain information.

Alert is used to display a message. The Syntax is as follows 

alert ("Message")  

Confirm 

You have a new method called confirm to get a confirmation. The syntax is as follows. 

Variable = confirm ("Message")  

Example 

<html>

<head>

<script>

var name=prompt("Enter name","anonymous")

function drawrule(width) {

document.write("<HR WIDTH="+width+"%>")

}

if (!confirm("Click ok if you are using Netscape")){

document.write("<center><b>Dear "+name)

drawrule(50)

document.write("Please use Netscape with JavaScript</b></

center>");

}

</script>

</head>

</html>  

User Input 

A third message box that you can use for obtaining user input is invoked with the prompt () method of the window object. Use the prompt dialog box when you want to obtain a value from a user. This dialog box features a message, an edit box for user input, and OK and Cancel buttons. The prompt () method has the following syntax: 

        returnValue = [window.]prompt(message, defaultReply)  

As you can see, in addition to specifying the message of the dialog box, you need to specify a defaultReply parameter. This value becomes the default text inserted in the edit box of the message box. You must specify this parameter, even if you have no default value. If the user clicks OK, the prompt () method returns the string value entered by the user. If nothing is entered in the edit box, an empty string ("") is returned. However, if the user clicks Cancel, a null value is returned. 

Output 

if you select cancel

 

Example

<html>

<head>

<title> Expression eval</title>

<script>

function com (form) {

form.result.value=eval(form.expression.value)

}   

</script>

</head>

<body>

<form>

<input type="text" name="expression" > =

<input type="text" name="result">

<p>

<input type="button"  name="a" value="Compute" onClick="com(this.form)">

<input type="button" value="Clear" onClick="this.form.expression.value=’’ ; this.form.result.value=’’”>

</form>

</body>

</html>

Output 

 

 


JSP Home | All JSP Tutorials | Latest JSP Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by aathishankaran
Web Security Issues
The Web User's Perspective
Server-side plug-Ins
The best way to avoid security vulnerabilities with new server
JavaScript Security
Window Object
Working with Status Bar Messages
Retrieving a Portion of a String
Referencing Windows
Math Object
Frame Object
Document Object
Closing Windows
Built-in Object in Javascript
Textarea Object

More Tutorials in JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
JSP Alert Example
JSP CheckBox Example
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
A JSP page that gets properties from a bean
The page Directive in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Declarations in JSP
Scriptlets and Expressions in JSP
Tag Libraries in JSP
The Request Object in JSP
The Response Object in JSP
The Out Object in JSP
The Session Object in JSP

More Latest News
Most Viewed Articles (in JSP )
JSP Example to connect to MS SQL database and retrieve records
What are the different scopes in JSP?
JSP Alert Example
JSP CheckBox Example
JSP Program for display Date
Comparison operators in JSP
Math Object
The Request Object in JSP
Form processing in JSP
Protecting your website with a login page
Textarea Object
The best way to avoid security vulnerabilities with new server
Server-side plug-Ins
Web Security Issues
JSP Example to connect to MS SQL database using Tomcat Connection Pool
Most Emailed Articles (in JSP)
The Servlet Life Cycle
Drawbacks of the JSP Model 1 Architecture
Working with Status Bar Messages
Embedding a QuickTime movie in a JSP
Embedding MP3 audio file in a JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
What is JSP?
Cookies using JSP or Java Bean
Click to Activate and Use this control
The JSP Program running first Time.
Scriptlets
Server Side Programming
Syntax For JSP Declaratives
Embedding java codes in jsp sciptlets
Tags using in jsp