tags:

views:

400

answers:

2

Hello,

I'm using a page unload trigger to warn the user of unsaved changes while leaving the page/closing the tab/etc... and this works fine.

//Exit event
if (!changes_saved) {
 window.onbeforeunload = confirmExit; 
}
function confirmExit()
{
  return "Your changes will be lost if you leave this page!";
}

My problem is that the browser (both Firefox and IE) enwraps the custom message with "Are you sure you want to navigate away from this page" in the beginning and with "Press OK to continue, or Cancel to stay on current page." at the end.

My question: is there any way to avoid this and completely customize the message in the dialog? Need for this isn't abstract, I'm developing a multi language interface and localized message mixed with the enforced one just looks silly.

Thank you.

A: 

I am afraid this is not possible. Had the same problem once, googled around for it and found a link on the msdn saying it cannot be done (for IE atleast which I was concerned about by then).

I can't find this link again though.

MahdeTo
+3  A: 

This question has been asked before.

Apparently, modifying this standard dialog is not possible because of browser security. If it were possible, it would allow a malicious site to fool you into staying on a page.

However, the language of the message is based on the language settings of the user's machine just like any other standard dialog.

Jose Basilio
+1 for stating facts without embellishment and for finding the link to the other question. I have fixed the link, though.
Cerebrus