Issue
I have my JavaScript alert on a page which alerts user with my custom message.
About my script, when a user try to exit or refresh a page they get alert with my custom message "Please Stay on this page to avail discount" When they choose to stay they are redirected to discount_offer.html
MY SCRIPT:
<script language="javascript">
    var vals=0;
    function displayMsg() {
        window.onbeforeunload = function evens(evt) {}
            window.location.href = 'discount_offer.html';
    }
    window.onbeforeunload = function evens(evt) {
    var message = 'Please Stay on this page to avail discount';
      if (typeof evt == 'undefined') {
          evt = window.event;
      }
        timedCount();
        vals++;
      if (evt) {
          evt.returnValue = message ;
          return message ;
      }
      trace(evt);
    }
    function timedCount()
    {
        t=setTimeout("timedCount()",100);
        if(vals>0)
        {
            displayMsg();
            clearTimeout(t);
        }
    }
    </script>
    
<p> <h1> My page Content here! </h1> </p>
>> PROBLEM:
My script works perfectly in Chrome, but it does not show my Custom Message in Firefox. Instead, it shows a Firefox default message:
"This page is asking you to confirm that you want to leave - data you have entered may not be saved"
>> My Question Is:
How can I get rid of this default Firefox message and show my message?
Solution
No, there's no way you can change it:
In FF 4 and later the returned string is not displayed to the user, as per this bug.
An alternative solution would be to highlight unsaved fields and/or put a message somewhere on the page.
Answered By - krisk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.