简体   繁体   中英

Javascript differences between Mobile Safari and Safari on Mac?

Hey this question is pretty general, but I'm wondering what the Javascript differences are in Mobile Safari and Safari for Mac.

I was under the impression that from a Javascript perspective they are the same, with only some differences in CSS/rendering. But I am experiencing a number of Javascript errors in Mobile Safari that don't exist in regular Safari on Mac.

Basically a number of calls to certain jQuery plugins are returning undefined values (according to the developer debugger in Mobile Safari).

The website that I'm experiencing these issues on has a very lousy front end that is riddled with validation errors, lousy JS and has an enormous amount of CSS attached. I have no doubt that this issue lies somewhere in this code, and I've never experienced issues like this before.

I'm just having trouble honing in on the problem, so any insight/links as to the general differences in Javascript engines would be much appreciated.

Javascript itself, the core language, is no different. There are a few significant differences in the DOM that appear undocumented, but mostly it is all the same. Here you can see some differences in events that you can handle.

The DOM differences I noticed had to do with measuring elements. For example getClientRects , at least for a Selection or Range, was not available. There are probably other things.

Before I add my two cents about differences in Safari depending on environment or build: the list of possible environments for Safari is bigger than just iPod, iPhone, iMac.

I am also dealing with: Safari for Windows (desktop) and Mobile Safari in iOS Simulator on iMac.

My jQueryMobile + PhoneGap app works nicely in Safari for Windows (desktop) and Safari on iMac, but it has the following problems in Safari on iOS Simulator on iMac Snow Leopard with XCode 3.x:

  1. Google Analytics gets a "whitelist rejection" in iOS simulator.
  2. My app hangs early on in the user's setup process through another problem

That other problem could be any of:

  1. tags placed after element may not be loading properly
  2. calls to localDb may not be coming through
  3. jQuery's events (pageinit,click,etc) may not come though in the same way

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM