Hi,

I've developed a website that works great with Firefox and IE but
cannot work properly with Android browser. The reason that I finally
found out is forms cannot be automatically submitted in Android
browser. Here is the code. On the client, I saw a pop-up window saying
"gears detected usr location" and then it hang there. The server
didn't receive any http request.

But if I add an submit button to the webpage, and after a user
explicitly clicks the submit button, the form is then successfully
submited.

Is it intentionally designed so that automatic form submission is
disabled? Is there a way to enable it? I don't like my workaround
solution; asking users to manually clicking submit button is kind of
annoying.

Thanks,
Hua

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>User Location Detection</title>
<script type="text/javascript" src="GoogleGears/gears_init.js"></
script>
<script type="text/javascript">

                function updatePosition(position) {
                        alert("gears detected usr location");
                        document.forms["theForm"].elements["getUsrLoc"].value = 
true;
                        document.forms["theForm"].elements["nextPage"].value =
"printerSelection.jsp";
                        document.forms["theForm"].elements["usrLocation"].value 
=
"latitude="+position.latitude+"\n longitude="+position.longitude;
                        document.forms["theForm"].submit();
                }

                function handleError(positionErr) {
                        alert("gears cannot detect usr location");
                        document.forms["theForm"].elements["getUsrLoc"].value = 
false;
                        document.forms["theForm"].elements["nextPage"].value =
"usrLocation.jsp";
                        document.forms["theForm"].submit();
                }

                function init() {
                        if (window.google && google.gears) {
                                // have google gears
                                alert("gears detected");
                                var geo = 
google.gears.factory.create('beta.geolocation');
                                geo.getCurrentPosition(updatePosition, 
handleError);
                        }
                        else {
                                alert("no gears");
                                
document.forms["theForm"].elements["getUsrLoc"].value = false;
                                
document.forms["theForm"].elements["nextPage"].value =
"installGears.jsp";
                                document.forms["theForm"].submit();
                        }
                }

        </script>
</head>
<body onload="init()">
        <div>
                <form name="theForm" id="theForm" method="post" 
action="mobileInit"
>
                        <input type="hidden" id="getUsrLoc" name="getUsrLoc"
value="getUsrLoc">
                        <input type="hidden" id="nextPage" name="nextPage"
value="nextPage">
                        <input type="hidden" id="usrLocation" name="usrLocation"
value="usrLocation">
                </form>
        </div>
        <div> detect user location, please wait...</div>
</body>
</html>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Android Discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/android-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to