Does Safari and/or WebKit implement the equivalent

2019-08-08 02:33发布

问题:

Does Safari have anything equivalent to the HTML 5.0 spec for window.navigator.online?

http://www.whatwg.org/specs/web-apps/current-work/#browser-state

If not are there any alternatives to polling to establish connectivity state?

My question pertains to Safari 4.0+ and iPhone software 2.1+

回答1:

Yes. I think it's been in Safari from 3.0 but I haven't checked. A quick test on the iPhone shows that it is available from iPhone OS 2.2.



回答2:

It's there, but it apparently isn't working (for me, on iPad with iOS 3.2.2). My code is showing it is always returning true, in both airplane mode and with the wireless explicitly turned off (I don't have 3G turned on). If someone else on an iPad has this working, I'd be interested in hearing about it.

It'd also be nice if Apple adopted navigator.connection (see link text), but that will obviously be a cold day in Hades before that happens.