Home > Article > Web Front-end > Solution to the problem of incorrect conversion of parseInt function in JavaScript's WebView in Android_javascript skills
I am troubled by a problem today. There is a page that runs well on the browser (whether it is a mobile phone or a PC), but there is a problem through WebView. There are two worthy calculations that always go wrong. So I used alert to display this value, and found that it was much different from the result calculated on the browser. It was originally a positive number, but it became a negative number. After careful comparison, it was found that some of the numbers were erased, and these numbers were converted from strings through parseInt. The only difference between the erased values and other normal numbers is that they all start with 0, such as "04903", while other values are "90874". In this case, the reason is obvious. The JavaScript parseInt supported by WebView converts all strings starting with 0 to 0. Once the problem is solved, it will be easier. Just write a str2Int method to replace parseInt.