473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Override onbeforeunload

Hi All,
I want to override the onbeforeunload event so that when the user
clicks on the close button, at the right top of the screen, it only
open an alert with OK button and don't close the screen

How can I do that???

thanks

regards,
Mohammed

Nov 29 '05 #1
5 6179
lightzizo wrote on 29 nov 2005 in comp.lang.javascript:
I want to override the onbeforeunload event
You can only override an js event if it is set beforehand.

so that when the user
clicks on the close button, at the right top of the screen, it only
open an alert with OK button and don't close the screen


That would be very impolite.
The window belongs to the user.

try:

window.onbeforeunload = bfunload;

function bfunload(){
alert("OK ?")
return false
}

Most or all browsers will not comply.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Nov 29 '05 #2
lightzizo wrote:
Hi All,
I want to override the onbeforeunload event so that when the user
clicks on the close button, at the right top of the screen, it only
open an alert with OK button and don't close the screen

How can I do that???

You can't. onbeforeunload will allow you to ask the browser to display a
confirmation box giving the user the option to cancel the close, but the
script itself cannot prevent the window closing.

Obviously, if you could prevent a window closing then popup advert writers
everywhere would do it all the time.
Nov 29 '05 #3
how can i prevent the user from closing the window???

Nov 29 '05 #4
lightzizo wrote:
how can i prevent the user from closing the window???

Which part of "You can't." did you not understand?
Nov 29 '05 #5
On 2005-11-29, lightzizo <m.*********@gmail.com> wrote:
how can i prevent the user from closing the window???


first you need to disconnect their computer's off button....

Bye.
Jasen
Dec 1 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robert Oschler | last post by:
I have a web page where I want to make sure that an image HTTP request is successfully made before the page unloads. The request is made by setting the image element's SRC property to the desired...
4
by: lltaylor | last post by:
Hello, Currently I use an onbeforeunload method, to do call various tidy up methods when a user exits my web application - however I now need to add additional support, for users migrating to...
6
by: jennyw | last post by:
Hi, I'd like to use onbeforeunload to submit a form before leaving a page. This works in Firefox and IE. Safari, however, blithely ignores this. Does anyone know of a workaround for Safari? Or...
4
by: sowencheung | last post by:
the bug of onbeforeunload is so obvious! in IE 6 it will popup twice "sometimes" I am using the following code window.onbeforeunload = null; window.onbeforeunload = confirmExit; var...
8
by: drewmania001 | last post by:
im currently using the following to prompt the user before navigating away from the page // add an unload event window.onbeforeunload = bunload; // function to prompt user function...
1
by: David | last post by:
I am using a process to warn users when they leave a page that there have been changes made. I took the example directly from Microsoft example I found in searching for help on the event...
5
by: allan.young | last post by:
Hi, When in gmail I'm composing a new email message and I bit the browser back button, I get a dialog that says "Your message has not been sent. Discard your message?" But if instead of...
1
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.