初始化是检测浏览器的类型

本文介绍如何使用Flex通过ExternalInterface调用JavaScript来直接获取浏览器信息,包括appName、userAgent和appVersion等,并提供了一个可运行的例子。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Hi Amit,

The replies from Gnomann are correct.

Following the logic that Gnomann cited in his second post (suggesting using ExternalInterface to execute browser JavaScript), following are some examples.

These examples also demonstrate how JavaScript methods can be written in-line directly in the ExternalInterface.call() execution:

var appName:String = ExternalInterface.call( "function getAppName(){ return navigator.appName; }" ) ;
var userAgent:String = ExternalInterface.call( "function getUserAgent() { return navigator.userAgent; }" ) ;
var appVersion:String = ExternalInterface.call( "function getAppVersion(){ return navigator.appVersion; }" ) ;


I have posted a different, runnable example here:
http://flexflashvideo.com/codesamples/flex/flex3/browserinfo/

You can right-click on the swf at the link above for " View Source "

btw ... an advantage of writing the JavaScript methods in-line in the ActionScript ExternalInterface.call() executions is that all of the code can be encapsulated in the Flex logic. That is you do not have to write the JavaScript separately in the HTML wrapper. You can if you want, of course. Certainly no harm in that ;-) Since your original question was how to detect the browser information "directly from FLEX", I suspect you might like being able to write the JavaScript methods in-line ;-)

Please post back regarding whether the above answers your question, and if you find it helpful :-)

Best regards,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值