|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
im using this script to use diferent css files
depending on the users browser type: <head> <script language="JavaScript" src="css.js"></script> <head/> css.js file <begin> <!-- if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt (navigator.appVersion)>= 4 )) { document.write('<link rel="stylesheet" type="text/css" href="ie45.css">')} else { if (navigator.appName == "Netscape"){ if (parseInt(navigator.appVersion)>= 5 ){ document.write('<link rel="stylesheet" type="text/css" href="ns6.css">')} else { document.write('<link rel="stylesheet" type="text/css" href="ns4.css">')} } else { document.write('<link rel="stylesheet" type="text/css" href="default.css">')} } //--> <end> but it doesnt work at all , and i would like to make a new one with opera support . anyone know if there is something wrong with the code ? i´ve desativated the firewall to test it .
__________________
--==::di50rd3R::==-- ExplicitPunk.U4L.com --==::di50rd3R::==-- |
|
#2
|
|||
|
|||
|
Here's how I would code that...
Code:
if (document.getElementById && !document.all) {
document.write('<link rel="stylesheet" type="text/css" href="ns6.css">')
} else if (document.all) {
document.write('<link rel="stylesheet" type="text/css" href="ie45.css">')
} else if (document.layers) {
document.write('<link rel="stylesheet" type="text/css" href="ns4.css">')
} else {
document.write('<link rel="stylesheet" type="text/css" href="default.css">')
}
|
|
#3
|
||||
|
||||
|
do u know how to add a new function for opera browsers
and does the ie part support 4 and 5 and 6 vertions |
|
#4
|
|||
|
|||
|
write yourself a test function to display the navigator.userAgent, etc, open it in Opera and see what you can test for.
yes...document.all covers ie4-6 |
|
#5
|
||||
|
||||
|
must i add this function
else if (navigator.userAgent) { document.write('<link rel="stylesheet" type="text/css" href="op.css">') } |
|
#6
|
|||
|
|||
|
No...(navigator.userAgent) will always be true. I downloaded Opera and tested some things. It understands document.getElementById and document.all, so it acts like IE. I have no idea how CSS might work differently, you might just test your IE css in opera and see how it looks. If you just have to use a different file...
Code:
var agent = "" + navigator.userAgent;
if (agent.indexOf("Opera") != -1 {
document.write('<link rel="stylesheet" type="text/css" href="op.css">');
} else if (document.getElementById && !document.all) {
document.write('<link rel="stylesheet" type="text/css" href="ns6.css">');
} else if (document.all) {
document.write('<link rel="stylesheet" type="text/css" href="ie45.css">');
} else if (document.layers) {
document.write('<link rel="stylesheet" type="text/css" href="ns4.css">');
} else {
document.write('<link rel="stylesheet" type="text/css" href="default.css">');
}
|
|
#7
|
||||
|
||||
) |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > js for css browser independent help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|