ActionScript 2, Detect Browser

I want to detect the browser type/version from within a Flash file. I can't use any server-side scripting, so I'm hoping to do it via Actionscript. Is this possible?

Thanks!
KaressaAsked:
Who is Participating?
 
CyanBlueConnect With a Mentor Commented:
You could use JavaScript's navigator.userAgent to tell the type and the version of the web browser...  Take a look at these pages for more information on that...
   http://www.w3schools.com/js/js_browser.asp
   http://www.javascriptkit.com/javatutors/navigator.shtml

So, what you need to do is to place this simple JavaScript function inside the HTML file...
      function getUserAgent()
      {
            return navigator.userAgent;
      }

and call it from the Flash like this: var ua:String = ExternalInterface.call("getUserAgent");

Once you receive the ua back from Flash, you can do a string manipulation to check what browser you are on...  This logic can be placed inside the JavaScript if you want to...  But I will leave that up to you...  Please check the attached file for more information...

CyanBlue
GetUserAgent.zip
0
 
KaressaAuthor Commented:
Sweet! Thanks!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.