Skip to Content
MOBILE WEB程式設計--第二版
book

MOBILE WEB程式設計--第二版

by Maximiliano Firtman
December 2013
Intermediate to advanced
752 pages
16h
Chinese
GoTop Information, Inc.
Content preview from MOBILE WEB程式設計--第二版
566
|
第十五章
網路資訊
Network Information API
http://www.w3.org/TR/netinfo-api
)可以讓我們知道一些關於
目前網路連線的資訊。在寫這本書時,有兩種 API 的實作可以使用:Android 瀏覽器與
Apache Cordova/PhoneGap App 率先實作的舊規格版本,以及 Blackberry 10 瀏覽器與行
Firefox 率先實作的 W3C 新規格,其中包括頻寬資訊。
舊規格
舊規格 API
http://bit.ly/10St3bL
)公開了一個
navigator.connection.type
屬性,它會匹
配下列字串之一:
unknown
ethernet
wifi
2g
3g
4g
none
雖然舊的 W3C 規格指出這個
type
屬性必須是字串,但 Android 瀏覽
器與 Apache Cordova 實作以整數來公開它的值,以對應至
navigator.
connection
常數。
這個 API 會給你第一個節點的連線類型,但不代表這個連線可以正常的運作,甚至也不
代表它是最終的連線類型。例如,現在的公車與火車上經常會有 WiFi,而且這些 WiFi
存取點可能會使用 3G 連線。
除了這個 API 之外,瀏覽器也公開兩種可以用來偵測連線狀態的事件:
online
offline
,以及
window.onLine
布林屬性。
當我們離線時,可以確定沒有網際網路連線、沒有 WiFi,也沒有基地台
連線。如果 API 指示我們位於線上,那只是代表有一個可用的連線,不代 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

成為卓越程式設計師的38項必修法則

成為卓越程式設計師的38項必修法則

Pete Goodliffe
精實企業|高績效組織如何達成創新規模化

精實企業|高績效組織如何達成創新規模化

Jez Humble, Joanne Molesky, Barry O'Reilly

Publisher Resources

ISBN: 9789862769522