Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

should close the browser with user confirmation in javascript

Ads

 
 

Share on Google+Share on Google+

K.Senthuran
should close the browser with user confirmation in javascript
2 Answer(s)      8 years ago
Posted in : Java Beginners
Ads
View Answers

November 5, 2008 at 2:12 PM


Hi
try the following code hope this will help u.if not then again post the problem.

<html>
<head>
<title>Detecting browser close </title>


<script type="text/javascript">

var myclose = false;

function ConfirmClose()
{
if (event.clientY < 0)
{
event.returnValue = 'If You want to close the browser';

setTimeout('myclose=false',100);
myclose=true;
}
}

function HandleOnClose()
{
if (myclose==true)
alert("Browser is closed");
}

</script>
</head>


<body onbeforeunload="ConfirmClose()" onunload="HandleOnClose()">

<h4>Close browser!</h4>

</body>
</html>


November 7, 2008 at 4:47 PM


Hi friend,

<html>
<head>
<title>close window</title>
</head>

<body onbeforeunload="alert('Do you want to close!');">
<h2>This simple close windows Program.</h2>
</body>
</html>


------------------------------------------------------

Thanks.

Ads









Related Tutorials/Questions & Answers:
should close the browser with user confirmation in javascript - Java Beginners
should close the browser with user confirmation in javascript  Hi, I need to close the browser with the user confirmation. If the user accept olny he/she can close the browser otherwise can't close the browser. How can I do
Closing any kind of browser window without confirmation using javascript
Closing any kind of browser window without confirmation using javascript  Here is my requirement, I have to close a browser window on onload event... help me in resolving this problem. It should support any kind of browser and any
Advertisements
Protractor close browser after test
Protractor close browser after test  Hi, I am writing test cases... to session related issues. I want to close and start browser. How to restart browser? I need to know the code for Protractor to close browser after test
closing the internet explorer window of any version without confirmation using javascript
closing the internet explorer window of any version without confirmation using javascript  Hi all, Here is my requirement, I have to close microsoft internet explorer window on onload event without confirmation. It should
Inform user to enable JavaScript
Inform user to enable JavaScript   Hi sir How can we inform user to turn on JavaScript ? Because if we have implemented validation etc... > tag to inform user or run any other code ,when JavaScript is turned off
Java code to executr db query if user directly closes the browser
Java code to executr db query if user directly closes the browser  How to execute a database query if the logged in user idle for 15 mins or he will directly close the browser.........PLS help it out
textfield should not allow the user to fill the date in it.
textfield should not allow the user to fill the date in it.  I got a requirement like this, I am dislaying a text field along with a calendar. Here user should not fill the date inside the text field manually. If he tries
Confirmation Mail
Confirmation Mail  hi, i need the code.when we sign up it will send the confirmation mail to the e-mail right.how to do that part.....and also help me whether the AJAX is better or PHP better for the front design
How to Collapse Dropdowns on mouseclick on scrollbar in Safari Browser using javascript
How to Collapse Dropdowns on mouseclick on scrollbar in Safari Browser using javascript  How to Collapse Dropdowns on mouseclick on scrollbar in Safari Browser using javascript
Browser Back Button click event javascript
Browser Back Button click event javascript  I am using the below code but window.onBeforeUnload is not working with back button.. how can i apply the below code for the click event of back button? window.onBeforeUnload
Show Confirmation Dialog on Click the Command Link
Show Confirmation Dialog on Click the Command Link  How to show Confirmation Dialog when user Click the Command Link
JavaScript User Defined Functions
JavaScript User-Defined Functions: An user-defined function saves  us... them to work. JavaScript has so many built-in functions, besides  that you can make your own as per the need. General structure of the user defined
How to create a confirmation box?
How to create a confirmation box?  How to create a confirmation box
Should we go for javascript or applets for online exam project using java
Should we go for javascript or applets for online exam project using java ... soon as the candidate login successfully a window pop up should appear with question and options. This window pop up should accomplish the entire monitor screen
problem of confirmation
;" /> </form> Javascript code whcish was given by you
How to disable back button in browser using javascript
in browser. Most common example of this is found in Online Banking Websites. Most of the time the back button is disabled because a user can hit back... that will disable the working of Back button in Browser: <SCRIPT type="
how to send smtp mail to entered user mail id after user registered using javascript?
how to send smtp mail to entered user mail id after user registered using javascript?  how to send smtp mail to entered user mail id after user registered using javascript
how to send smtp mail to entered user mail id after user registered using javascript?
how to send smtp mail to entered user mail id after user registered using javascript?  how to send smtp mail to entered user mail id after user registered using javascript
browser
browser  how to make a browser
JFrame Close On Button Click
JFrame Close On Button Click In this section we will discuss about how to close frame on click on the button. This example explains you how a frame can be closed on an action event i.e. a frame should be close when clicked
browser
browser  hello this is saurav srivastav, thank you for sending the cvode for creating the menu item, but I want the code for file open and save frame in the swing because I am working on my project Browser and one more problem
email confirmation - Hibernate
functionality on user registration. My user should reply/click on registration email link after that I should read user data from hibernate/MySql and make some..., than I have to update user but I am not sure how should I select user and finally
JavaScript
should use JavaScript? Thanks   Hi, JavaScript is scripting language that runs on browser. You have to embed JavaScript in HTML page. Please see JavaScript tutorial. Thanks
need solution to get file name from path which should give by user
need solution to get file name from path which should give by user  how do i write a program in java that i should get file path from arguments.currently this code creates the file at d:\ but i need to get this file name
SWT Browser
Browser implements the browser and allows the user to navigate through HTML... SWT Browser       This section shows you SWT Browser In SWT, the class Browser of package
Calling In JavaScript Functions from HTML Form To Validate User Entered Data
Calling In JavaScript Functions from HTML Form To Validate User Entered... and editing my html to call my functions to validate the user entered data...;title>Subscription Form</title> <script type="text/javascript">
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
Browser issue
Browser issue  how can i close popup windows in mozilla browser and return back to the parent page
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.  I have a tex box. in that i want user should enter data in the format specified(for eg--abcde_)how
PHP SQL close connection
PHP SQL close connection       PHP SQL close connection is used to close a connection between the PHP... 'PHP SQL close Connection'. To understand and grasp the example we include
Closing the browser window
Closing the browser window  <BODY> <form> <input type=button value="Close Window" onClick="javascript:window.close();"> <...; thought that this will close the window of the browser but not working