Hi all, I am a newbie here. So please I need your help. I have written a small piece of code for browser detection in JavaScript. It is working fine in case of Mozilla but when I run it on Explorer (IE), then for application code and user agent, it shows the name of the Mozilla. I do not know why this is happening? Please can some one help me and figure out this thing?
Thanks in advance
Regards;
Raza

Recommended Answers

All 3 Replies

cant fix it if you dont show it
show the code you are using

Thanks for your reply, here is my code. Please check it and let me know why this happens.
Thanks

<html>
<head>
<title>Javascript Example 1</title>
<script type="text/javascript">
    function detectBrowser(){
        (document.getElementById("appCode")).innerHTML = navigator.appCodeName;
        (document.getElementById("appName")).innerHTML = navigator.appName;
        (document.getElementById("appVersion")).innerHTML = navigator.appVersion;
        (document.getElementById("userAgent")).innerHTML = navigator.userAgent;
        (document.getElementById("platForm")).innerHTML = navigator.platform;       
    }
</script>
</head>
<body>
    <b>Application Code: </b><div id="appCode"></div><br />
    <b>Application Name: </b><div id="appName"></div><br />
    <b>Application Version: </b><div id="appVersion"></div><br />
    <b>User Agent: </b><div id="userAgent"></div><br />
    <b>Platform: </b><div id="platForm"></div><br />
    <input type="button" value="Check Browser" onclick="detectBrowser();">
</body>
</html>

**edit** before the mods get to it, please wrap code in [code]

[/code] tags, makes it easier to follow **

Why in javascript, your problem I prefer serverside

compatible mozilla, many browser user_agents report compatibilities
the browser agents are different, you just have to test for unique items, the word mozilla is not unique

probably not the answer you wanted, but at least its accruate, the mozilla test is firefox

Application Name:
Microsoft Internet Explorer

Application Version:
4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Avant Browser; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

User Agent:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Avant Browser; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

Platform:
Win32

Application Name:
Microsoft Internet Explorer

Application Version:
4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Avant Browser; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

User Agent:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Avant Browser; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

Platform:
Win32

Application Name:
Microsoft Internet Explorer

Application Version:
4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Avant Browser; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

User Agent:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Avant Browser; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

Platform:
Win32

opera reports IE7, in this case

Application Name:
Opera

Application Version:
9.63 (Windows NT 5.1; U; en)

User Agent:
Opera/9.63 (Windows NT 5.1; U; en) Presto/2.1.1

Platform:
Win32

Application Name:
Netscape

Application Version:
5.0 (Windows; en-US)

User Agent:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 3.5.30729)

Platform:
Win32

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.