should close the browser with user confirmation in javascript

should close the browser with user confirmation in javascript

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.









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
ModuleNotFoundError: No module named 'django-user-action-confirmation'
ModuleNotFoundError: No module named 'django-user-action-confirmation' ...: ModuleNotFoundError: No module named 'django-user-action-confirmation' How to remove the ModuleNotFoundError: No module named 'django-user-action-confirmation' error
ModuleNotFoundError: No module named 'django-user-action-confirmation'
ModuleNotFoundError: No module named 'django-user-action-confirmation' ...: ModuleNotFoundError: No module named 'django-user-action-confirmation' How to remove the ModuleNotFoundError: No module named 'django-user-action-confirmation' error
ModuleNotFoundError: No module named 'django-user-action-confirmation'
ModuleNotFoundError: No module named 'django-user-action-confirmation' ...: ModuleNotFoundError: No module named 'django-user-action-confirmation' How to remove the ModuleNotFoundError: No module named 'django-user-action-confirmation' error
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
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
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
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
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
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:ADS_TO_REPLACE_1 <
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
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
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
How to create a confirmation box?
How to create a confirmation box?  How to create a confirmation box
browser
browser  how to make a browser
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
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
problem of confirmation
;" /> </form> Javascript code whcish was given by you
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
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">
Browser issue
Browser issue  how can i close popup windows in mozilla browser and return back to the parent page
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
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
PHP SQL close connection
PHP SQL close connection       PHP SQL close connection is used to close a connection between the PHP... an example from 'PHP SQL close Connection'. To understand and grasp the example
JavaScript Hello World
the JavaScript code within html coding, to display the output in  a browser...Hello World Program in JavaScript To write and run a JavaScript program all we need to have a text file and a internet browser. First of all write
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
why cant i close this ??
why cant i close this ??  import java.util.Scanner; public class...("Thank you "); } } i should use while to get the square of the number entered by the user
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
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
prevent browser refresh
prevent browser refresh   prevent browser from refresh in Javascript
JavaScript
JavaScript  clone JavaScript
how to close JSF application..?
how to close JSF application..?  how to close jsf appliaction using command button with help of java code
Javascript code
from which you have come,and the via page At the top of the confirmation page we can see Student Regd->Student Detail->Confirmation..The link should...Javascript code  Dear Sir, Thank you a lot for your support
Javascript code
which you have come,and the via page At the top of the confirmation page we can see Student Regd->Student Detail->Confirmation..The link should be visible...Javascript code  Thank you a lot for your support throughout
javascript
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
JavaScript - JavaScript Tutorial
interactive user interface design. What is JavaScript? This section... functions via javascript: URLs Conditionally navigating the user to a page... JavaScript Tutorials is one of the best Quick reference to the JavaScript
JavaScript - JavaScript Tutorial
interactive user interface design. What is JavaScript? This section... functions via javascript: URLs Conditionally navigating the user to a page... JavaScript Tutorials is one of the best Quick reference to the JavaScript
javascript
javascript  javascript code to dynamically add table on button click.../javascript/javascriptexamples/javascript-add-row-dynamically.shtml http://www.roseindia.net/javascript/javascript-add-row-to-table.shtml http://www.roseindia.net
close a Connection application
close a Connection application  What happens when I close a Connection application obtained from a connection Pool? How does a connection pool maintain the Connections that I had closed through the application
Javascript
Javascript  in the web form the phonenumber field should be like this format xxx-xxx-xxxx, i want the code in javascript. as a function.   Javascript Phone Number Validation <html> <script> function
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
JavaScript
JavaScript  how to get full path of a file type in javascript
javascript
javascript  Hi deepak, how to write form validation on javascript

Ads