PDA

View Full Version : Confirm message !


chrissy
10-04-2002, 04:13 AM
Hi,


Do you have a source code for me to study for the confirm message.


Something like this.

for example im filling up the new thread form then suddenly i decided to go to my user profile link then once i click the other module like User Profile, a Confirm message will appear that says Going to this module without saving will result to lost of any unsave information! confirm of ok and cancel


Or something that im filling up this form then i accidentally close the browser window then a confirm message will appear and says closing this window without saving will result to lost of any unsave information! confirm of ok and cancel


i think this idea is very useful to all the users for them to be reminded by those confirmation message when they accidentally close the browser or go to another module without saving.


And even this Forum can use that confirm message that i think was very useful.


Is it possible?


thanks,

chrissy

chrismiceli
10-04-2002, 04:34 AM
here is some examples

//the onclose confirm
function test() {
var hi = confirm("Are you sure you want to leave");
if (hi == true) {
//whatever the closeit function is, i can't remember now
}
else parent.top.location.href = "your url";
}
<body onUnload="test()">


that syntax can be used for a lot of things, very useful

if i am wrong someone tell me, i often am by little mistakes

glenngv
10-04-2002, 06:17 AM
using onunload event will not prevent the user from leaving the page, you can only detect that the page is being unloaded. So even if the user choose Cancel in the prompt, the page will still unload.

In IE, there is onbeforeunload event which you can use.
follow the link http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onbeforeunload.asp