 |
HTML Help Please Search for the answer to your question before asking it! Thanks.
|
| View previous topic :: View next topic |
| Author |
Message |
Maggical
Joined: 10 Jan 2005
Posts: 46
Location: Rosario - Argentina
|
| Posted: Wed Jun 24, 2009 5:53 pm Detecting Browser and Loading CSS |
|
|
Hi there, I've been using a javascript for a long time now, that loads a different css if the user has Internet Explorer 6...
The thing is that I now want to load different things in many other cases, I would need:
- Internet Explorer 6 or below
- Internet Explorer 7 or above
- Firefox
- Safari
Any idea on how to tweak my code to make it work?
Here it is:
Code: <script type="text/javascript">
// Function to include the css
function includeCSS(src) {
document.write('<link rel="stylesheet" type="text/css" href="'+src+'">');
}
// Detection begins
version=0;
if(navigator.appVersion.indexOf("MSIE")!=-1){
temp=navigator.appVersion.split("MSIE");
version=parseFloat(temp[1]);
}
//If it's not IE it returns 0
if((version>=6.0) && (version<7.0)){
// Case IE6
includeCSS("css/leftIE6.css");
}
else{
// All the other cases
includeCSS("css/left.css");
}
</script>
And here's some info that I can't work around to make it work:
http://www.javascriptkit.com/javatutors/navigator.shtml
Thanks a lot,
Javier |
|
|
Maggical
Joined: 10 Jan 2005
Posts: 46
Location: Rosario - Argentina
|
| Posted: Wed Jun 24, 2009 6:09 pm |
|
|
For those of you who have the same problem, here's a workaround using jQuery:
http://agachi.name/weblog/archives/2006/07/22/avoiding-css-hacks-using-javascript.htm
Good luck! |
|
|
| |
|
|
|
Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group
|