Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    179
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Stop Browser's Message When Change Page

    For either latest Firefox or IE, I tried to inform the user that he/she has made changes on the current form, and if the he/she wants to save the changes.

    So on the jsp, I coded:
    <script>
    window.onbeforeunload= function(){
    if (checkAnyChange() == "true"){
    displayCustomMessageModal();
    return false;
    }
    };
    </script>
    The problem is that during the process, the browser displayed its own standard warning message such as displaying:"This page is asking you to confirm that you want to leave - data you have entered may not be saved." Leave | Stay

    How can I suppress this message programmingly?

    I do not want to manually disable the message, for I can not predict how the users will set up their browsers.

    Thanks to help

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,915
    Thanks
    56
    Thanked 545 Times in 542 Posts
    you haven't been able to do it in FF since FF4:
    https://developer.mozilla.org/en-US/...onbeforeunload

    Don't why they don't fix it. Didn't know that IE had gone the same way. Don't know if there's a workaround.

    (don't know much, it seems...)

  • Users who have thanked xelawho for this post:

    otnj2ee (02-28-2013)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by otnj2ee View Post
    How can I suppress this message programmingly?

    Sorry, you can't.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    otnj2ee (02-28-2013)

  • #4
    Regular Coder
    Join Date
    Apr 2007
    Posts
    179
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Given the fact that I can not stop the browser's standard warning message, is there a work around if I want to display a custom message instead, when the use tries to close the browser or navigate away from the current page (by using the Back or Forward button)?

  • #5
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,915
    Thanks
    56
    Thanked 545 Times in 542 Posts
    how is that question different from the first one you asked?

  • #6
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,296
    Thanks
    10
    Thanked 583 Times in 564 Posts
    Quote Originally Posted by otnj2ee View Post
    Given the fact that I can not stop the browser's standard warning message, is there a work around if I want to display a custom message instead, when the use tries to close the browser or navigate away from the current page (by using the Back or Forward button)?
    no, that kind of crap sucks, which is why it's getting removed left and right.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,618
    Thanks
    0
    Thanked 645 Times in 635 Posts
    My understanding is that the latest browsers now only allow the use of onbeforeunload to produce the standard message - support for attaching your own custom code to that non-standard event is being dropped.

    While there are a small number of legitimate uses for being able to attach code to this event, most use appears to be simply to annoy visitors to the page by trying to prevent them leaving - and hence to ensure that they will never come back. Given how annoying it is when misused this way I am surprised that browsers still support it at all.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #8
    Regular Coder
    Join Date
    Apr 2007
    Posts
    179
    Thanks
    17
    Thanked 0 Times in 0 Posts
    While I am here. How can I dynamically trigger the browser's Back or Forward button? For example, when in javascript,

    if (condition == "1") automatically trigger the browser's Back buton

  • #9
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,915
    Thanks
    56
    Thanked 545 Times in 542 Posts
    sounds to me like you should visit www.annoyingwebsitefeatures.com

    they'll have all your answers there.

  • #10
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,618
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by otnj2ee View Post
    While I am here. How can I dynamically trigger the browser's Back or Forward button? For example, when in javascript,

    if (condition == "1") automatically trigger the browser's Back buton

    if (condition == "1") history.back();
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    otnj2ee (02-28-2013)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •