1

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.

  • enforced message is in user's language of choice (i.e. browser language), so, are you sure that it will be different to your language? – SilentGhost May 16 '09 at 14:39
  • Absolutely, in my subjective opinion 90%+ of windows users do not use localized versions of the OS, and firefox on SuSe linux seams to ignore the language setting. –  May 16 '09 at 15:19

2 Answers2

4

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.

Community
  • 1
  • 1
Jose Basilio
  • 50,714
  • 13
  • 121
  • 117
  • +1 for stating facts without embellishment and for finding the link to the other question. I have fixed the link, though. – Cerebrus May 16 '09 at 15:36
0

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
  • 11,034
  • 2
  • 27
  • 28