473,395 Members | 1,343 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,395 software developers and data experts.

Firefox close forbid

Hello,
Is exiting a possibility to forbid the click on the close cross ?
Otherwise, can we put a js treatment in order to don't lose the informations
on the form ?

Thanks, Skot.
Oct 3 '05 #1
3 3191
Skot wrote:
Hello,
Is exiting a possibility to forbid the click on the close cross ?
No.
Otherwise, can we put a js treatment in order to don't lose the informations
on the form ?
Firefox and Mozilla support 'window.onbeforeunload' (though it doesn't
seem to have made it into the on-line documentation yet) that allows you
to prompt a user to not close a window.
<script type="text/javascript">

window.onbeforeunload = function() {alert('hi'); return false;};

</script>


Thanks, Skot.

--
Rob
Oct 3 '05 #2
On 03/10/2005 01:33, RobG wrote:

[snip]
window.onbeforeunload = function() {alert('hi'); return false;};


A beforeunload listener should return a string. This string will be
displayed in a dialog box that asks whether the user wishes to navigate
away from the current document. So,

window.onbeforeunload = function() {return 'Hi';};

would be more appropriate.

You can't cancel the event programatically; the whole point is for the
user to handle it.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Oct 3 '05 #3
Michael Winter wrote:
On 03/10/2005 01:33, RobG wrote:

[snip]
window.onbeforeunload = function() {alert('hi'); return false;};

A beforeunload listener should return a string. This string will be
displayed in a dialog box that asks whether the user wishes to navigate
away from the current document. So,

window.onbeforeunload = function() {return 'Hi';};

would be more appropriate.

You can't cancel the event programatically; the whole point is for the
user to handle it.


Thanks Mike.

I couldn't find any documentation on the Mozilla site (it seems to be a
fairly recent inclusion), the Microsoft doco wasn't very clear - their
example used window.event.

Hopefully the following is better:
function savePrompt()
{
var unsavedData = true;

// Do some test to determine if there is unsaved data
// if unsavedData = true, message is shown
// if unsavedData = false, navigation is not interrupted

if ( unsavedData ){
var message = 'You have unsaved data.'
+ '\nLeaving this page without saving'
+ ' will cause the data to be lost';
return message;
}
}

window.onbeforeunload = savePrompt;

--
Rob
Oct 3 '05 #4

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

Similar topics

1
by: Bill H | last post by:
I run a dbms application that interfaces with the web. This module creates a frames page with two frames ('main' and 'mwinfoframe'). All communication with the dbms is routed through the...
14
by: franz | last post by:
hallo everyone, i have a popup window 500x400px centered in the middle of the screen and inside it there's a mini-photogallery. what i want is to click on a thumbnail and open in the same window a...
4
by: stevong | last post by:
It works on Konquerer though. I remember it works on IE too. I've tried window.close() too. Doesn't work on Firefox also. I've also tried to create a function. It doesnt work on Firefox also....
4
by: evgenyg | last post by:
Hello ! We have the following situation - when Ajax request is sent what's being returned by the server is usually an XML (which is used for DOM updates) but sometimes it's HTML which is a whole...
4
by: Andre | last post by:
With Firefox 1.5+, I used the following code to close a window/tab: === <html><head> <script language="javascript" type="text/javascript"> function closeWindow() { window.open('','_parent','');...
1
by: nebulus | last post by:
I'm working on a web app that under normal circumstances will be happy with the Session_OnEnd event, but when a user leaves a page by closing the browser by either Alt+F4 or just hitting the "X",...
4
by: badaczewski | last post by:
The following javascript appears on a popup window. <script language="javascript" type="text/javascript"> function InsertContact(value) { window.opener.CallBackContact(value); window.close();...
17
by: ur.solame | last post by:
I have an image being generated by a PHP script-- I didn't write the code-- and the image itself is in a database. I've discovered that there is a big discrepancy between how the images appear...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.