|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I ran across a PHP script that would read your browser and then assign the proper CSS link for the browser.
The orginal version can be found at : +------------------------------------------------------------------+ | MikeCherim.com | | PHP: Browser Sniffer | | PHP Hypertext Preprocessor | | Copyright July 2006 | | Use with attribution by visible link please! | | Attribute to: <a href="http://green-beast.com/">Mike Cherim</a> | +------------------------------------------------------------------+ Thought I would share my version. Found it to be helpful for a project that I am working on right now. This is the core file I named it "browsers.inc.php" <?php function load_css() { $ua_ok= $_SERVER['HTTP_USER_AGENT']; // First the Windows( PC) browsers **************************** // Win Internet Explorer 7.0 if( eregi( "Windows", $ua_ok ) && eregi( "msie", $ua_ok ) && eregi( "[7]\.[0]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" media="screen" />' ); } // Win Internet Explorer 6.x or AOL 9.x elseif( eregi( "Windows", $ua_ok ) && eregi( "msie", $ua_ok ) && eregi( "[6]\.[0-9]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" media="screen" />' ); } // Win Internet Explorer 5.5 elseif( eregi( "Windows", $ua_ok ) && eregi( "msie", $ua_ok ) && eregi( "[5]\.[5]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" media="screen" />' ); } // Win Firefox 3.0 elseif( eregi( "Windows", $ua_ok ) && eregi( "firefox", $ua_ok ) && eregi( "[1]\.[9]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Win Firefox 2.0 elseif( eregi( "Windows", $ua_ok ) && eregi( "firefox", $ua_ok ) && eregi( "[1]\.[8]\.[1]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Win Firefox 1.5.0 elseif( eregi( "Windows", $ua_ok ) && eregi( "firefox", $ua_ok ) && eregi( "[1]\.[5]\.[0]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Win Firefox 1.0.7 elseif( eregi( "Windows", $ua_ok ) && eregi( "firefox", $ua_ok ) && eregi( "[1]\.[0]\.[7]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Win Mozilla 1.7.12 elseif( eregi( "Windows", $ua_ok ) && eregi( "mozilla", $ua_ok ) && !eregi( "netscape", $ua_ok ) && eregi( "rv:[1]\.[7]\.[12]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Win Mozilla 1.6 elseif( eregi( "Windows", $ua_ok ) && eregi( "mozilla", $ua_ok ) && eregi( "rv:[1]\.[6]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Win Netscape 6.2 elseif( eregi( "Windows", $ua_ok ) && eregi( "netscape", $ua_ok ) && eregi( "[6]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Win Safari 3 elseif( eregi( "Windows", $ua_ok ) && eregi( "safari", $ua_ok ) && eregi( "[3]\.[0]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Now the Mac browsers **************************************** // Mac Firefox 2.0 elseif( eregi( "Macintosh", $ua_ok ) && eregi( "firefox", $ua_ok ) && eregi( "[1]\.[8]\.[1]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Mac Firefox 3.0 elseif( eregi( "Macintosh", $ua_ok ) && eregi( "firefox", $ua_ok ) && eregi( "[1]\.[9]", $ua_ok ) ) { echo( '<link href="www.ecarttemplates.com/css/elayoutFF2_0_MAC.css" rel="stylesheet" type="text/css" />' ); } // Mac Opera 9.x elseif( eregi( "Macintosh", $ua_ok ) && eregi( "opera", $ua_ok ) && eregi( "[9]", $ua_ok ) ) { echo( '<link href="www.ehttp://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Mac Safari 2.0 elseif( eregi( "Macintosh", $ua_ok ) && eregi( "safari", $ua_ok ) && eregi( "[417]\.[0-9]\.[0-9]", $ua_ok ) ) { echo( '<link href="http://www.http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } // Mac Safari 2.0.4 elseif( eregi( "Macintosh", $ua_ok ) && eregi( "safari", $ua_ok ) && eregi( "[419]\.[0-9]", $ua_ok ) ) { echo( '<link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" />' ); } } ?> ----------------------------------------------------------------------------------------------- Then in your index.php top of page <?php require "browsers.inc.php" ?> Then within the head tag below <link href="http://www.yourdomain.com/css/layout.css" rel="stylesheet" type="text/css" /> insert <?php load_css() ?> It really helped me hope it can help someone.... |
|
|||
|
Neat script, thanks for sharing... got rep
Question: Shouldn't each code call a different css file? or am i not getting it? ps, your site took forever to load
__________________
----Don't Call Me Brian---- |
|
|||
|
Thanks,
Yes each css file can be different if needed. You could render a completely different site base on each browser type. I am upgrading the site and about to move it to a new server. When finished it will have every shopping cart system I have found showing features and overall functionality. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Helpful Strategy? | SEOforGoogle | Marketing Strategies Discussion Forum | 6 | 11-14-2007 11:23 AM |
| PHP help - function call | bilabong | Web Programming Discussion Forum | 0 | 07-22-2007 07:56 AM |
| PHP isset () function | kurt.santo | Web Programming Discussion Forum | 2 | 07-02-2007 04:47 AM |
| PHP Function Calls via Links? | southplatte | Web Programming Discussion Forum | 4 | 07-27-2004 11:47 PM |
| Feedback would be helpful | kimmichelle | Introductions | 0 | 05-07-2004 08:01 PM |
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |