jquery 1.6.2 works on Android 2.1 emulator but not on Samsung Galaxy S
Has anyone else encountered the problem that jquery-1.6.2.min.js does not at all seem to work on a Samsung Galaxy S running Android 2.1? And if so, does anyone know what modification开发者_高级运维s I can make to be able to use it for this device?
I recently started to develop a mobile version of a javascript-based web site I made earlier this year. All went fine and everything seemed to work on both a wide range of Android emulators as well as my own Samsung Galaxy S2. But when I tested the site on a Samsung Galaxy S1 running the standard Android 2.1, all my javascript code seemed to be broken. So I went back to testing it once again on the emulators for both Android 2.1 and the Galaxy Tab (using the default WebKit browser), and on those the site worked just fine.
I tried numerous solutions and searched the web non stop for differences between the standard Android 2.1 and the one with which the Galaxy S ships, until I decided to downgrade the Jquery version I was using from 1.6.2 to 1.4.2. This solved my problem immediatly. However, because of improvements made to jquery for use with mobile devices, I would still like to be able to use 1.6.2.
Thanks in advance.
Edit Nov 5:
As Manuel Holzhauser points out, replacing "//" by '//' in the jQuery 1.6.2 script solves the problem. It seems to have something to do with the combination of two forward slashes and double quotation marks, as both the latter and "/* are used in the script with no problem.
For reference, the code snippet with the single occurence of "//" reads:
// Main method
ajax: function( url, options ) {
var // Create the final options object
s = jQuery.ajaxSetup( {}, options ), // (...)
// Remove hash character (#7531: and string promotion)
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
// We also use the url parameter if available
s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
// (...)
}
We had exactly the same problem, but I have found the solution!
You have to replace "//"
with '//'
in your compressed version.
It changes nothing in functionality but it will work on your phone!
I would attempt to run the jQuery unit tests when confronted with a new device or with the problems you are having (http://docs.jquery.com/Qunit)
精彩评论