Android browser: Some javascript functions stop working randomly
I am writing an android (2.2) app which launches the default native web browser via a new Intent to a page I've created. On that page, it pauses for 2 seconds before then submitting a form, which redirects the user to another page.
I am using javascript's setTimeout() function.
It works most of the time, but then sometimes it just stops working, and won't work again until I restart the phone!
There are NO javascript errors which appear in LogCat.
Even stranger, to counteract this I put a link on the page that says "If the page has not redirected in 5 seconds click here". It submits the form when clicked, via onClick() and .submit(). Well, again, it usually works, but, when the setTimeout() function stops working, so does the link! But, I have confirmed that alert() still works, so some javascrip开发者_如何学JAVAt functions apparently still work.
Any ideas why setTimeout() and .submit() would just randomly stop working, until the phone is reset?
EDIT: I've also confirmed that window.location doesn't work anymore either, but, if you just have a regular link, it does actually let you click on it, and it leaves the page.
EDIT: It appears that you can get this problem to happen more quickly if you hit STOP and REFRESH a few times while waiting for the setTimeout to fire off. Basically if I hit stop, then refresh, then stop, then back, etc, a couple times, I can get this problem to happen. After it starts, no amount of refreshing or killing/restarting the browser will make these javascript functions start working again.
Thanks! Richard
I came across this post that may be of help: http://www.barneyb.com/barneyblog/2011/02/20/settimeout-bug-in-android-2-2/
精彩评论