Skip to main content

Search and Top Navigation

#8034 closed bug (notabug)

Opened January 20, 2012 09:45AM UTC

Closed November 30, 2012 12:40PM UTC

Last modified November 30, 2012 01:14PM UTC

Malfunction after cancel the "onBeforeUnload" prompt in Android Browser

Reported by: pigletso Owned by: pigletso
Priority: minor Milestone: 1.10.0
Component: ui.dialog Version: 1.8.17
Keywords: Cc:
Blocked by: Blocking:
Description
Browser: Android browser (Android 2.3.5)
Version: 1.6.2 & 1.7.1(Jquery), 1.8.16 & 1.8.17(JqueryUI)
OS: Android

I was developing a website using UIDialog and using "onBeforeUnload" javascript method to warn use when leave the page.

Desktop browser chrome and firefox works great but I tried in my Galaxy S2 with Android version 2.3.5 default browser and malfunctioned.

Here are the steps to the bug:

1. Create a webpage with a button to open a UIDialog.

2. Setup the "onBeforeUnload" javascript method.

3. Use Android browser to open the webpage.

4. Exit the page and press "Don't exit" when asking if you want to exit.

5. Press the button to open the UIDialog.(<- cannot setup UIDialog in my main project, failed in $('#dialog').dialog({}) function)

6. Try to close the UIDialog.(<- cannot close in my blank test page(I just pressed the right upper corner "x" button of the UIDialog))

Here is the test page I used(Jquery 1.6.2 & JqueryUI 1.8.16):

<!doctype html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>
            Moblie test page
        </title>
        <!-- JQuery -->
        <script src="jqueryui/js/jquery-1.6.2.min.js"></script>
        <!-- JQuery UI -->
        <script src="jqueryui/js/jquery-ui-1.8.16.custom.min.js"></script>
        <link rel="stylesheet" href="jqueryui/css/smoothness/jquery-ui-1.8.16.custom.css" type="text/css" />
        <script>
            function popup(){
                $('#dialog').dialog('destory');
                $('#dialog').dialog({
                    modal: true,
                    title: "popup"
                });
            }
            window.onbeforeunload = function(){
                return "Click false and try popup again.";
            }
        </script>
    </head>
    <body>
        <input type="button" value="Popup" onclick="popup();"/><br />
        <input type="button" value="Exit" onclick="window.location.reload();"/>
        <div id="dialog">
        </div>
    </body>
</html>
Attachments (0)
Change History (13)

Changed January 22, 2012 08:17PM UTC by tj.vantoll comment:1

Test case - http://jsfiddle.net/MbNfr/3/embedded/result/

On Android 2.3.4 I wasn't prompted in the default browser when I clicked the Exit button, it just refreshed the page. I couldn't find anything online about Android's support of the function. Running typeof window.onbeforeunload returns function, but it doesn't seem to do anything. Since I wasn't prompted when I clicked Exit I can't recreate this issue and don't really know how I could.

Anyways, you have "destroy" spelled wrong on this line, which might create issues.

$('#dialog').dialog('destory');

Changed January 23, 2012 11:02PM UTC by scottgonzalez comment:2

owner: → pigletso
status: newpending

@pigletso Does tj's test case fail for you?

Changed January 24, 2012 07:47AM UTC by pigletso comment:3

status: pendingnew

Replying to [comment:2 scott.gonzalez]:

@pigletso Does tj's test case fail for you?

It worked the same as you mentioned: it just refreshed the page

And desktop browser worked well.

May be this test have to work with real page instead of jsfiddle?

Thank you for the wrong spelling issue.

Changed January 24, 2012 01:03PM UTC by scottgonzalez comment:4

status: newpending

@pigletso Ok, can you try against http://jsfiddle.net/MbNfr/3/show then? That will render the same code but as a normal page, with nothing from jsFiddle present. If that page also works for you, then we can dig into the differences between that and your code and figure out what exactly is causing the failure.

Changed January 24, 2012 02:59PM UTC by pigletso comment:5

status: pendingnew

Replying to [comment:4 scott.gonzalez]:

@pigletso Ok, can you try against http://jsfiddle.net/MbNfr/3/show then? That will render the same code but as a normal page, with nothing from jsFiddle present. If that page also works for you, then we can dig into the differences between that and your code and figure out what exactly is causing the failure.

This time my android browser could cancel from exiting the page, but it failed when I want to popup the UIDialog again.

Failed at the fifth action

5. Press the button to open the UIDialog.

Changed January 25, 2012 10:52AM UTC by tj.vantoll comment:6

I'm seeing the issue now as well. This does work on mobile Firefox.

Changed January 25, 2012 03:59PM UTC by pigletso comment:7

Replying to [comment:6 tj.vantoll]:

I'm seeing the issue now as well. This does work on mobile Firefox.

Yes this is work on Firefox but I was targeting the default Android browser one.

I also tried in other mobile browser, some of them were created by using WebKit was failed in this test too.

Changed January 26, 2012 03:30AM UTC by tj.vantoll comment:8

If I remove $('#dialog').dialog('destroy') this works fine - http://jsfiddle.net/MbNfr/5/show/

That line is unnecessary, the code is smart enough to reuse the same instance since you're using the same div. Also, in 1.9 calling destroy before initialization throws an error (see #5972).

Changed October 11, 2012 02:47PM UTC by scottgonzalez comment:9

milestone: 1.9.01.10.0

Changed October 16, 2012 02:04PM UTC by bavanyo comment:10

status: newopen

Changed November 30, 2012 11:31AM UTC by jzaefferer comment:11

If I remove $('#dialog').dialog('destroy') this works fine

So is this issue invalid then? Looks to me like that.

Changed November 30, 2012 12:40PM UTC by mikesherov comment:12

resolution: → notabug
status: openclosed

This issue IS invalid. Seems like it was erroneously set to open before tj. vantoll had appropriate privileges to close this.

Changed November 30, 2012 01:14PM UTC by tj.vantoll comment:13

Replying to [comment:12 mikesherov]:

This issue IS invalid. Seems like it was erroneously set to open before tj. vantoll had appropriate privileges to close this.

Correct.