Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Javascript / VB Script JavaScript and VBScript are interpreted, scripting languages that let you embed simple programs into Web pages. JavaScript/VBScript programs are embedded directly within the HTML document. When the browser loads the HTML document, the programs are also loaded.

Javascript / VB Script Thread, Getting Browser details and Version Detection using JavaScript in Web Development; Getting Browser details and Version Detection using JavaScript Getting Browser details and Version Detection using JavaScript We work hard to ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=6753


Reply
LinkBack Thread Tools Display Modes
Getting Browser details and Version Detection using JavaScript
 
 
The God Father
Developer's Avatar

Reply With Quote
 
Join Date: Jul 2008
Location: NDC
Posts: 5,425
27-11-2008, 07:50 PM
 
Getting Browser details and Version Detection using JavaScript


Getting Browser details and Version Detection using JavaScript

We work hard to get more traffic to make our web portal or blog popular. We use various tips and techniques to achieve our goals. We go for search engine optimization, forum and discussion boards. We put our back link there. People use it and from different parts of the world people comes to our web portal or blog. They have different platform, operating systems, and different web browsers. Some time we fail to serve page compatible to them. And pages not get properly display and next time they avoid to come back. Get your browser details here...
To avoid such situation analysis of traffic plays an important role. In this article we will go to get browser details of the web browser using JavaScript. We are going see how to get it. We can used that data to store in database and used for analyse it, so we can modify our site structure to make it more compatible with different version of web browser. Here we are not going to store it in database, we just going to display it in web browser itself. Here navigator object will play an important role. The navigator Object describes more modern ways to accomplish browser-version detection.
The navigator Object

Despite a name reminiscent of the Netscape Navigator-branded browser, the navigator object is implemented in all scriptable browsers. All browsers also implement a handful of properties that reveal the same kind of information that browsers send to servers with each page request. Thus, the navigator.userAgent property returns a string with numerous details about the browser and operating system.
For example, a script running in Internet Explorer 7 in Windows Vista receives the following value for the navigator.userAgent property: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 1.1.4322; InfoPath.2; FDM; .NET CLR 3.5.21022)
The same script running in Firefox 1.5 on a Macintosh reveals the following userAgent details:
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13
Getting More Details

Now we will go get more details. The first thing we need to do is access the platform property of the navigator object—the value of this property will tell us which platform the user is on. navigator.appName will gives you browser name, Please see below peace of code: <h3> Your Browser details are as follows:</h3>
<script language="javascript" type="text/javascript">
var StrDummy = navigator.appVersion;
strVersion = StrDummy.substring(0,4);
document.write("<center><table border=1 cellpadding=2><tr><td>");
document.write("<center><b>", navigator.appName,"</b>");
document.write("</td></tr><tr><td>");
document.write("<center><table border=1 cellpadding=2><tr>");
document.write("<td>Code Name: </td><td><center>");
document.write("<b>", navigator.appCodeName,"</td></tr>");
document.write("<tr><td>Version: </td><td><center>");
document.write("<b>",strVersion,"</td></tr>");
document.write("<tr><td>Platform: </td><td><center>");
document.write("<b>", navigator.platform,"</td></tr>");
document.write("<tr><td>Pages Viewed: </td><td><center>");
document.write("<b>", history.length," </td></tr>");
document.write("<tr><td>Color depth: </td><td><center>");
document.write("<b>", window.screen.colorDepth," Bits </td></tr>");
document.write("<tr><td>Java enabled: </td><td><center><b>");
if (navigator.javaEnabled()){
document.write("Yes !</td></tr>");
if(navigator.appName != "Microsoft Internet Explorer") {
vartool=java.awt.Toolkit.getDefaultToolkit();
addr=java.net.InetAddress.getLocalHost();
host=addr.getHostName();
ip=addr.getHostAddress();
document.write("<tr><td>Host Name: </td><td><center>");
document.write("<b>",host,"</td></tr>");
document.write("<tr><td>IP Address: </td><td><center>");
document.write("<b>",ip,"</td></tr>");
}
}
else document.write("No!</td></tr>")
document.write("<tr><td>Screen Resolution: </td><td><center>");
document.write("<b>",screen.width," x ",screen.height,"</td></tr>");
document.write("</table></tr></td></table></center>");
</script>
When you test code in Microsoft Internet Explorer you will get output as follows:

Egypt.Com EnForum
As some feature of Java not supported by Microsoft Internet Explorer you can’t get details like IP address and hostname. You can get it on Mozilla Firefox. I got following output we i have tested above code in Mozilla Firefox.
Egypt.Com EnForum
Source Code:

Download Source code for 'Getting Browser details and Version Detection using JavaScript '

Download


__________________
I Love Walking In The Rain Cuz Nobody Know I'm Crying !!
 
 
 
Reply

Javascript / VB Script Thread, Getting Browser details and Version Detection using JavaScript in Web Development; Getting Browser details and Version Detection using JavaScript Getting Browser details and Version Detection using JavaScript We work hard to ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=6753


Bookmarks

Tags
browser, details, detection, javascript, version


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mobile Phone / iPhone / PDA Detection and Style Assignment Developer Mods for 3.7.x 14 29-04-2009 04:30 AM
Adding Javascript to your Template Developer Articles 0 27-10-2008 09:44 PM
CyberDefender Early Detection Center™ Developer Software and Programs 0 01-10-2008 09:17 PM
Get Memory Details Through WMI Class Developer Classes & Source Code 0 31-08-2008 06:45 PM
Egypt buys new system for tunnel detection SABRAWY News 0 25-12-2007 05:51 PM