Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8160749

WebView does not support window.onbeforeunload

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 8u66, 9
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
      None
    • Subcomponent:
      web
    • Introduced In Version:
    • CPU:
      x86
    • OS:
      windows_8

      Description

      JavaFx WebView does NOT support window.onbeforeunload=true. In All other major browsers, doing this will ask the user whether they want to leave or not (they probably have unsaved changes).

      Since the applet will be no longer supported, we ´╝łOracle) have suggested that sites use webstart to startup a WebView and overlay the java ontop.
       
      Our suctomers can't do this successfully without having support for window.onbeforeunload=true since our HTML pages rely on that feature.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try this jsfiddle in a WebView, when attempting to leave the the page in all major browsers, you will be given some sort of confirm action dialog:

      https://jsfiddle.net/zalun/yFuPr/

      Here is the javascript to reproduce yourself on a WebView:
      window.onbeforeunload = function(e) {
          e = e || window.event;
          e.preventDefault = true;
          e.cancelBubble = true;
          e.returnValue = 'test';
      }

      Expected Behavior:
      confirmation dialog on attempt to re-navigate browser
      ACTUAL -
      no confirmation dialog, unsaved changes will be lost

      Reproducing test program is attached.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                gucheng Guixin Cheng
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: