Hi,
does anybody know the JavaScript the guys at Microsoft used in MS CRM to prevent people from closing a browser window and asking them (on the client) what they really want to do? If you don't know what I'm talking about take a look at MS CRM. Open a form, make some changes and try to close the form without saving first. Instead of closing the form you will be asked if you'd like to save first or discard the changes. I have often asked myself how to design this behavior.
Thank you in advance.
Best regards
Daniel Walzenbach
P.S. If you need to contact me simply remove ".NOSPAM" from my email address. 8 9204
I dont have code handy - but this is how it works.
You initially load the page with a hidden field of a value 0, and Onchange
event in a client editable item (like a textbox) would set the value to be 1
(indicating a change). On submit - run a function that checks the value of
1 or zero and issues a prompt.
--
Regards
John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_auth or_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_autho r_plug>
----------------------------------------------
"Daniel Walzenbach" <da************ **********@freu denberg.de> wrote in
message news:O4******** ******@TK2MSFTN GP12.phx.gbl...
Hi,
does anybody know the JavaScript the guys at Microsoft used in MS CRM to
prevent people from closing a browser window and asking them (on the client)
what they really want to do? If you don't know what I'm talking about take a
look at MS CRM. Open a form, make some changes and try to close the form
without saving first. Instead of closing the form you will be asked if you'd
like to save first or discard the changes. I have often asked myself how to
design this behavior.
Thank you in advance.
Best regards
Daniel Walzenbach
P.S. If you need to contact me simply remove ".NOSPAM" from my email
address.
John,
thank you for your quick answer. I know that it must be done like this
(theoretically) , but I don't know exactly what to do to prevent a user from
closing a web form?
I'd be thankful if you or anybody else who knows could provide me with a
more detailed approach of how to solve this problem.
Thank you.
Best regards
Daniel
"John Timney (Microsoft MVP)" <ti*****@despam med.com> schrieb im Newsbeitrag
news:ON******** ******@TK2MSFTN GP09.phx.gbl... I dont have code handy - but this is how it works.
You initially load the page with a hidden field of a value 0, and Onchange event in a client editable item (like a textbox) would set the value to be
1 (indicating a change). On submit - run a function that checks the value
of 1 or zero and issues a prompt.
-- Regards
John Timney (Microsoft ASP.NET MVP) ---------------------------------------------- <shameless_auth or_plug> Professional .NET for Java Developers with C# ISBN:1-861007-91-4 Professional Windows Forms ISBN: 1861005547 Professional JSP 2nd Edition ISBN: 1861004958 Professional JSP ISBN: 1861003625 Beginning JSP Web Development ISBN: 1861002092 </shameless_autho r_plug> ----------------------------------------------
"Daniel Walzenbach" <da************ **********@freu denberg.de> wrote in message news:O4******** ******@TK2MSFTN GP12.phx.gbl... Hi, does anybody know the JavaScript the guys at Microsoft used in MS CRM to prevent people from closing a browser window and asking them (on the
client) what they really want to do? If you don't know what I'm talking about take
a look at MS CRM. Open a form, make some changes and try to close the form without saving first. Instead of closing the form you will be asked if
you'd like to save first or discard the changes. I have often asked myself how
to design this behavior. Thank you in advance.
Best regards
Daniel Walzenbach
P.S. If you need to contact me simply remove ".NOSPAM" from my email address.
"Daniel Walzenbach" <da************ **********@freu denberg.de> wrote in
message news:us******** ******@TK2MSFTN GP12.phx.gbl... John,
thank you for your quick answer. I know that it must be done like this (theoretically) , but I don't know exactly what to do to prevent a user
from closing a web form?
You want to be a little careful here. You might be able to find a way to
keep a user from inadvertently closing a web form, but you're not going to
be able to shut off all the ways a user could do himself damage. The user
can always turn off his computer, for instance. Less drastically, are you
preventing the user from using the "back" button or keystroke, or
JavaScript?
--
John Saunders
Internet Engineer jo***********@s urfcontrol.com
Hi Daniel,
Based on my research and experience, we can hook the onbeforeunload event
of the body tag. Here is the sample HTML, please try it.
<HTML>
<HEAD>
<SCRIPT>
function closeIt()
{
event.returnVal ue = "Any string value here forces a dialog box to \
appear before closing the window.";
}
</SCRIPT>
</HEAD>
<BODY onbeforeunload= "closeIt()" >
<a href="http://www.microsoft.c om">Click here to navigate to
www.microsoft.c om</a>
</BODY>
</HTML>
Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.
Best regards,
Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Jacob,
Again you helped me and I am really thankful. Have a wonderful day.
Daniel
"Jacob Yang [MSFT]" <ji***@online.m icrosoft.com> schrieb im Newsbeitrag
news:EK******** ******@cpmsftng xa06.phx.gbl... Hi Daniel,
Based on my research and experience, we can hook the onbeforeunload event of the body tag. Here is the sample HTML, please try it.
<HTML> <HEAD> <SCRIPT> function closeIt() { event.returnVal ue = "Any string value here forces a dialog box to \ appear before closing the window."; } </SCRIPT> </HEAD> <BODY onbeforeunload= "closeIt()" > <a href="http://www.microsoft.c om">Click here to navigate to www.microsoft.c om</a> </BODY> </HTML>
Does it answer your question? If I have misunderstood your concern, please feel free to let me know.
Best regards,
Jacob Yang Microsoft Online Partner Support Get Secure! ¨C www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
They used the onbeforeunload event as such:
function window.onload()
{
window.attachEv ent("onbeforeun load", OnClose);
}
function OnClose()
{
event.returnVal ue = "Are you sure you want to close this window?";
}
"Daniel Walzenbach" <da************ **********@freu denberg.de> wrote in
message news:uH******** ******@TK2MSFTN GP10.phx.gbl... I want to open a web form without the navigation bar (this is no problem
and I know how to do this). Next would be that a user changes data on this
page and clicks the (x) at the upper right to close the form. I then want to
stop the page from being closed and ask the user if he wants to save his
changes. If he chooses to do so then I want to jump back in the code behind and
save the data, otherwise the form will be shut.
Daniel,
After the user enters some data on the page, and before the user submits the
form, has any data been sent to the database? If not, you might want to
consider the fact that the user probably intended for the window to close
when he clicked the "x". He probably had no reason to believe his data would
be saved. So when you prompt him, he's probably going to click the "shut the
damned window like I told you to!" button. I know I would.
--
John Saunders
Internet Engineer jo***********@s urfcontrol.com
Bear in mind that while Jakobs code allows you to correctly prompt the user,
it does not determine if the user has changed anything in the screen, so you
will need to add in the extra step to ensure that you have this covered.
Also, it will always prompt - even if the user has not changed anything -
which may be a wee bit tedious for an end user. So take the example and
expand on it to get the best out of what is being suggested here.
--
Regards
John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_auth or_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_autho r_plug>
----------------------------------------------
"Daniel Walzenbach" <da************ **********@freu denberg.de> wrote in
message news:Oy******** ******@tk2msftn gp13.phx.gbl... Jacob, Again you helped me and I am really thankful. Have a wonderful day. Daniel
"Jacob Yang [MSFT]" <ji***@online.m icrosoft.com> schrieb im Newsbeitrag news:EK******** ******@cpmsftng xa06.phx.gbl... Hi Daniel,
Based on my research and experience, we can hook the onbeforeunload
event of the body tag. Here is the sample HTML, please try it.
<HTML> <HEAD> <SCRIPT> function closeIt() { event.returnVal ue = "Any string value here forces a dialog box to \ appear before closing the window."; } </SCRIPT> </HEAD> <BODY onbeforeunload= "closeIt()" > <a href="http://www.microsoft.c om">Click here to navigate to www.microsoft.c om</a> </BODY> </HTML>
Does it answer your question? If I have misunderstood your concern,
please feel free to let me know.
Best regards,
Jacob Yang Microsoft Online Partner Support Get Secure! ¨C www.microsoft.com/security This posting is provided "as is" with no warranties and confers no
rights.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Maria Bitsku |
last post by:
How do I deactivate a window using Javascript. For example if I have
a window that opens up another window, how do I prevent the user from
clicking (doing anything) in the original window until the new window
has been closed. Any insight will help. Thank you very much in
advanced.
|
by: Johnny Knoxville |
last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works
fine if you add the site to favourites the normal way, but I have some
JavaScript code on a couple of pages with a link, which when you click it
bookmarks the site (much easier). The favicon is never saved if the site
is bookmarked this way. Does anyone have any ideas...
|
by: Kai Grossjohann |
last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window.
That's fine, I don't need to do anything about it.
But Ctrl-N in IE appears to clone the current window. Is there a way
to intercept the key so that I can do stuff on the server side to make
the new window behave correctly?
(We have a JSP-based webapp which stores state in...
|
by: danny |
last post by:
Is there a way I can prevent the browser window from being closed? I'd
like to make sure the browser window only closes programatically (I want
to make sure the user enters data before moving on).
Another possible solution would be to re-open the window when it's
closed.
Any help is appreciated, thanks.
|
by: dsnyder |
last post by:
This HTML has a bit of Javascript at the end that puts the initial
focus on the userID field. It works great on Windows2000 running IE6,
but the initial focus never goes to the userID field on Windows 2003
PocketPC (Windows Mobile) running Pocket IE.
<html><head><title>WMS - P280WF100 - Login</title><META
HTTP-EQUIV='expires' VALUE='0'>...
| |
by: CW |
last post by:
I wrote an HTML based chat application. The front end is built entirely on
HTML + javascript. Essentially, I have a hidden frame that's refreshed
frequently and any new messages are displayed in another frame using
document.write. My problem is that since chat screen can be obscured by
other applications/windows, I have no way of informing...
|
by: Daniel Walzenbach |
last post by:
Hi,
does anybody know the JavaScript the guys at Microsoft used in MS CRM to prevent people from closing a browser window and asking them (on the client) what they really want to do? If you don't know what I'm talking about take a look at MS CRM. Open a form, make some changes and try to close the form without saving first. Instead of...
|
by: Jaggu |
last post by:
Hi ,
I need to close main window, once the child window succesfully opens
else main window to remain. In my case when I close the main window
immediately after the "window.open()" as mentioned below, both the main
and child disappears(this is due to pop up blocker) disappears
suddenly. I want to make the browser know if pop up blocks the...
|
by: karthik juneni |
last post by:
Hi all,
Iam trying to capture windows closing event (i.e) when the user clicks
on the "X" button i want to capture that event and want to update some
values in the database.I tried two methods but iam getting problems
with the two methods.
First,one i tried with
function Unload()
|
by: Jimmy |
last post by:
It is also possible for popup window to call function in main window
by using the opener property. Will "opener.someFunctionInMain(param1,
param2)" in the popup window work?
It's possible for main window to call function in the popup window,
right? The following is a sample code (close popup window causes to
show alert window) which...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |