Advanced Web Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Iron Speed
 
Go Back   Dev Articles Community ForumsWeb DesignAdvanced Web Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old June 17th, 2007, 04:03 PM
jaggedstone jaggedstone is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 1 jaggedstone User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 31 sec
Reputation Power: 0
Anyone good with javascript (browser detection --> css?)

Hi everyone. I don't know if anyone will know the answer to this but I figured I'd try anyway >.<

I am trying to use a browser detection script for my new website but I'm not quite sure how to make it to include Safari in the detection. Can anyone help? Thanks in advance.

Here is what I have so far:

Code:
if(-1 != navigator.userAgent.indexOf("MSIE"))
{
// Internet Explorer
document_write('.. rel="stylesheet" type="text/css" href="ie.css">');
}
else if (-1 != navigator.userAgent.indexOf("Mozilla"))
{
// Netscape
document_write('.. rel="stylesheet" type="text/css" href="netscape.css">');
}
else
{
// other
document_write('.. rel="stylesheet" type="text/css" href="other.css">');
}

Reply With Quote
  #2  
Old June 18th, 2007, 10:26 AM
¤| battousai |¤ ¤| battousai |¤ is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 30 ¤| battousai |¤ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 17 m 53 sec
Reputation Power: 2
Hi,

I'm not so strong on Javascript myself, but have some knowledge of it.

To include safari in the detection script, I would sudjest you have javascript look for something that sets safari appart from other browsers.

here is a script that will give you all the details about your current browser, hope this helps.

Code:
javascript
function test_browser() {
  var version = navigator.appVersion;
  var name = navigator.appName;
  var language = navigator.language;
  var code = navigator.appCodeName;
  var agent = navigator.userAgent;
  var platform = navigator.platform;
  var windowFeatures = 'Width=500, Height=350, Toolbar=no, Scrollbars=yes, Menubar=no';
  
  myWin = window.open('','',windowFeatures);
  myWin.document.write('<HTML><HEAD><TITLE>uw browser');
  myWin.document.write('</TITLE></HEAD><BODY Bgcolor="Ivory">');
  myWin.document.write('<H2>Details of your browser:</H2>');
  myWin.document.write('<TABLE Cellspacing=5><TR><TD>Naam:</TD><TD>', Name, '</TD></TR>');
  myWin.document.write('<TR><TD>Taal:</TD><TD>', language, '</TD></TR>');
  myWin.document.write('<TR><TD>Version:</TD><TD>', versie, '</TD></TR>');
  myWin.document.write('<TR><TD>Browser Codenaam:</TD><TD>', code, '</TD></TR>');
  myWin.document.write('<TR><TD>Useragent:</TD><TD>', agent, '</TD></TR>');
  myWin.document.write('<TR><TD>Platform:</TD><TD>', platform, '</TD></TR>');
  myWin.document.write('</TABLE>');
  myWin.document.write('<FORM><DIV Align=center><Input Type="button" Value="sluiten" onClick="self.close()">');
  myWin.document.write('</DIV></FORM>');
  myWin.document.write('</HTML>');
}


and then put this on the page:
Code:
javascript
<input type="submit" onClick="test_browser()" title="check my browser">


also check out W3Schools. They have alot of usefull info on javascript

Reply With Quote
  #3  
Old June 21st, 2007, 09:12 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Using Javascript to present different stylesheets to different browsers is usually frowned upon. Typically the difference in browser-rendering is minimal, and there's often CSS hacks to get around that. You might want to consider a different route.
Comments on this post
Itsacon agrees!
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #4  
Old June 22nd, 2007, 03:15 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information. Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 541313 Folding Title: Super Ultimate Folder - Level 2Folding Points: 541313 Folding Title: Super Ultimate Folder - Level 2Folding Points: 541313 Folding Title: Super Ultimate Folder - Level 2Folding Points: 541313 Folding Title: Super Ultimate Folder - Level 2Folding Points: 541313 Folding Title: Super Ultimate Folder - Level 2Folding Points: 541313 Folding Title: Super Ultimate Folder - Level 2Folding Points: 541313 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 19 m 48 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
Indeed. Usually when you need browser-detection, you're only introducing browser incompatibility. Just validate your HTML and CSS using the validators provided by the W3C and it should pretty much work on all existing browsers.
Comments on this post
ezenaide agrees!
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 263

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignAdvanced Web Development > Anyone good with javascript (browser detection --> css?)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway