• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to detect browser & version?

Engaged ,
Apr 24, 2012 Apr 24, 2012

Copy link to clipboard

Copied

how to detect browser & version in as3?

TOPICS
ActionScript

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 24, 2012 Apr 24, 2012

Copy link to clipboard

Copied

Hi Venkon,

You can use ExternalInterface.call("window.navigator.userAgent") with this u can detect the browser details.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 24, 2012 Apr 24, 2012

Copy link to clipboard

Copied

that is detected total like : Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727;

but i want only like  MSIE 8.0

or

Firefox 11.0

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 24, 2012 Apr 24, 2012

Copy link to clipboard

Copied

Use this code

package

{

    import flash.display.Sprite;

    import flash.external.ExternalInterface;

    import flash.events.MouseEvent;

    import fl.transitions.Tween;

    import fl.motion.easing.Elastic;

    public class Main extends Sprite

    {

        private var userAgent:String;

        public function Main():void

        {

            more.addEventListener(MouseEvent.MOUSE_UP, showFull);

            browserTxt.text = getUserAgent();

       

        }

        private function getUserAgent():String

        {

            try

            {

                userAgent = ExternalInterface.call("window.navigator.userAgent.toString");

                var browser:String = "[Unknown Browser]";

                if (userAgent.indexOf("Safari") != -1)

                {

                    browser = "Safari";

                }

                if (userAgent.indexOf("Firefox") != -1)

                {

                    browser = "Firefox";

                }

                if (userAgent.indexOf("Chrome") != -1)

                {

                    browser = "Chrome";

                }

                if (userAgent.indexOf("MSIE") != -1)

                {

                    browser = "Internet Explorer";

                }

                if (userAgent.indexOf("Opera") != -1)

                {

                    browser = "Opera";

                }

            }

            catch (e:Error)

            {

                //could not access ExternalInterface in containing page

                return "[No ExternalInterface]";

            }

            return browser;

        }

        private function showFull(e:MouseEvent):void

        {

            info.fullInfo.text = userAgent;

            var tween:Tween = new Tween(info,"y",Elastic.easeOut,info.y-10,180,0.5,true);

        }

    }

}

place a textfield on stage with instance browserTxt and a button with instance more and movieclip with instance info inside movieclip place a textfield with instance fullInfo. Test it

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 27, 2012 Apr 27, 2012

Copy link to clipboard

Copied

LATEST

already tested this one. but this is showing full address like

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727;

but i want only like  MSIE 8.0

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines