2009年02月18日


Flex内部からのブラウザ判定


特にブラウザが表示している HTML 内に JavaScript の function を用意する必要はありません。
var str:String = ExternalInterface.call("window.navigator.userAgent.toLowerCase");
if (str.indexOf("msie") > -1) {
	Alert.show("IE");
}
else if (str.indexOf("firefox") > -1) {
	Alert.show("Firefox");
}
else if (str.indexOf("opera") > -1) {
	Alert.show("Opera");
}
else if (str.indexOf("netscape") > -1) {
	Alert.show("Netscape");
}
else if (str.indexOf("chrome") > -1) {
	Alert.show("Google Chrome");
}
else {
	Alert.show("Unknown");
}



ただ、この場合ブラウザからの戻り値を取得するので、
IE では必ず OBJECT 要素が必ず必要でかつ id 属性が必要です。

また、こちらのような問題 も注意して下さい。

posted by night wálker at 15:50 | Flex3
記事リスト