Prototype 1.6.0 で大きく進化したイベント API(目次)
Prototype 1.6.0 RC の変更点、特にイベント周りの API の変更についてまとめた記事のインデックス。
Prototype 1.6.0 で大きく進化したイベント API (4)
Prototype 1.6.0 RC のイベント API について紹介するシリーズも今回が最後。
Prototype 1.6.0 で大きく進化したイベント API (3)
Prototype 1.6.0 RC イベント API の進化、更なるつづき。
Prototype 1.6.0 で大きく進化したイベント API (2)
随分と間が空いてしまった。前回の記事 Prototype 1.6.0 で大きく進化したイベント API に引き続き、Prototype 1.6.0 RC で導入された、イベント API の変更点を見ていく。
WebKit のブラウザ判定と iPhone、そして iPod touch
Prototype 1.6.0 のブラウザ判定と iPhone では、
prototype.js には 1.5.1 から、各種ブラウザを判定するための Prototype.Browser が定義されている。
として prototype.js のブラウザ判定コードを紹介した。iPhone を含む WebKit ベースのブラウザも判別できる。
WebKit Detect script
Surfin’ Safari の WebKit Detect script updated for iPhone and iPod touch で知った。WebKit detection script というものがあるらしい。
記事では iPhone と iPod touch もサポートしたよ、と書かれている。ソースコードではこんな感じ、
WebKitDetect.isWebKit = function isWebKit()
{
return RegExp(" AppleWebKit/").test(navigator.userAgent);
}
...
WebKitDetect.isMobile = function isMobile()
{
return WebKitDetect.isWebKit() && RegExp(" Mobile/").test(navigator.userAgent);
}
つまり、User-Agent に、
- "AppleWebKit/" があれば WebKit
- "Mobile/" があれば携帯端末
ということのようだ。
ここで、prototype.js のブラウザ判定コードを復習してみる。
MobileSafari: !!navigator.userAgent.match(/iPhone.*Mobile.*Safari/)
User-Agent に "iPhone" という文字列を想定していることからも、おそらく iPod touch では動作しないだろう。まあ、すぐ直るだろうけど。