Application.OpenURL crashes Firefox on WebGL

Hi folks, I’m new to Unity.

I use following code to quit my application, but the WebGL build crashes my Firefox when I call Application.OpenURL(). WebPlayer build works fine.

void Update ()
{        
    // Exit game?
    if (Input.GetKeyDown (KeyCode.Escape)) {
        if (Application.platform == RuntimePlatform.WebGLPlayer
            || Application.platform == RuntimePlatform.WindowsWebPlayer
            || Application.platform == RuntimePlatform.OSXWebPlayer) {
            // Browsers go back to home
            Application.OpenURL ("http://localhost/");
        }
        #if UNITY_EDITOR
        else if (Application.platform == RuntimePlatform.WindowsEditor
            || Application.platform == RuntimePlatform.OSXEditor) {
            // Editors stop game mode
            UnityEditor.EditorApplication.isPlaying = false;
        }
        #endif
        else {
            // Standalone builds just quit
            Application.Quit ();
        }
    }
}

Is this a known issue? Or, I should not even use Application.OpenURL to quit my browser application?

Some spec reports:

Unity 5.1.0f3

Firefox 38.0.5: WebGL - Crashes on Application.OpenURL

Chrome: WebGL - Works fine

IE: WebGL - Whole app crashes (I know it’s not well supported yet, so it’s ok.)

There seems indeed to be an issue. I reported it as a bug and sent it to the developers.

OpenURL indeed does not currently work on WebGL. You’ll need to create a simple javascript plugin to handle onMouseUps, and handle your onMouseDowns to send events to said plugin. It sounds complicated, but it’s simple once you get it. But you’ll probably lose a couple hours to get it working the first time: