Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 02-12-2011, 08:45 PM browser detection
Ultra Talker

Posts: 254
Trades: 0
i would like to detect safari 3 browser so that i can style safari 3 separately

i am using
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>

<script type="text/javascript" language="javascript">
$(document).ready(function() {
if ($.browser.webkit){}
$("div").css();
});
</script>

if i use if ($.browser.webkit){} this will detect both safari and chrome and will apply styles to both browsers

i tried

if ($.browser.webkit && ($.browser.version = "534.13") ){
alert("webkit chrome");
$("body").css("background","#555555");
}

if ($.browser.webkit && ($.browser.version = "3.2.3") ){
alert("webkit safari 3");
$("body").css("background","#cccccc");
}

when i use alert to see the version of chrome and safari on my machine i get
534.13 for chrome and 3.2.3 for safari

here both chrome and safari and taking #555 color first and then #ccc

how do i differentiate between chrome and safari so that i can style them differently


also i am using firefox 3.6.8 but when i use the alert to detect version
var x = $.browser.version;
instead of 3.6.8 it shows 1.9.2.8

when i clicked on help-about for firefox
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 GTB7.1 ( .NET CLR 3.5.30729; .NET4.0C)

so it is taking from here

so if i were to style separately for firefox without using -moz should i check
the firefox version as 3.6.8 or 1.9.2.8


for ie it displays as version 6, 7


also to use $.browser is
http://code.jquery.com/jquery-1.5.min.js

correct to use or should another version of jquery to be used
sudhakararaog is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-14-2011, 08:22 AM Re: browser detection
Extreme Talker

Posts: 246
Trades: 0
in the if statements you are assigning values, not comparing, use === instead of =
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
Reply With Quote
View Public Profile
 
Old 02-14-2011, 10:41 AM Re: browser detection
Skilled Talker

Posts: 83
Trades: 0
try following code example, i have found in w3schools

<div id="example"></div>

<script type="text/javascript">

txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
txt+= "<p>Browser Name: " + navigator.appName + "</p>";
txt+= "<p>Browser Version: " + navigator.appVersion + "</p>";
txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
txt+= "<p>Platform: " + navigator.platform + "</p>";
txt+= "<p>User-agent header: " + navigator.userAgent + "</p>";

document.getElementById("example").innerHTML=txt;

</script>
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
DmitryS is offline
Reply With Quote
View Public Profile
 
Old 02-22-2011, 03:51 PM Re: browser detection
Banned

Posts: 4
Name: victorwan
Trades: 0
JavaScript Browser Detection to certain browsers a specially on older browser. some time useful to detect visitor's browser and serve the information. Visitor's browser using name, version, and other information.
victorwan is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to browser detection
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27997 seconds with 12 queries