Jump to content

browser detection not working..........please help me


unplugged_web

Recommended Posts

I have a web page that works in all browsers except IE7. To control the css that is loaded I've created a file:

var d, dom, ie, ie4, ie5x, moz, mac, win, lin, old, ie5mac, ie5xwin, op;d = document;n = navigator;na = n.appVersion;nua = n.userAgent;win = ( na.indexOf( 'Win' ) != -1 );mac = ( na.indexOf( 'Mac' ) != -1 );lin = ( nua.indexOf( 'Linux' ) != -1 );if ( !d.layers ){	dom = ( d.getElementById );	op = ( nua.indexOf( 'Opera' ) != -1 );	konq = ( nua.indexOf( 'Konqueror' ) != -1 );	saf = ( nua.indexOf( 'Safari' ) != -1 );	moz = ( nua.indexOf( 'Gecko' ) != -1 && !saf && !konq);	ie = ( d.all && !op );	ie4 = ( ie && !dom );	/*	ie5x tests only for functionality. ( dom||ie5x ) would be default settings. 	Opera will register true in this test if set to identify as IE 5	*/	ie5x = ( d.all && dom );	ie5mac = ( mac && ie5x );	ie5xwin = ( win && ie5x );	if ( moz ){		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/right.css" />');	}	else if ( op ){		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/right.css" />');	}	else if ( saf ){		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/right.css" />');	}	else if ( konq ){		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/right.css" />');	}	else if ( ie5mac ) {		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/right.css" />');	}	else	{		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/right_ie.css" />');	}}

but when I'm in IE7 right_ie.css doesn't seem to load and I don't understand why or what I can do about it.Please help.....

Link to comment
Share on other sites

There is a much easier way and it works even with JS off. It's call conditional comments.

<head>  <link type="text/css" rel="stylesheet" href="/css/right.css"/>  <!--[if IE]><link type="text/css" rel="stylesheet" href="/css/right_ie.css"/><![endif]--></head>

Link to comment
Share on other sites

There is a much easier way and it works even with JS off. It's call conditional comments.
<head>  <link type="text/css" rel="stylesheet" href="/css/right.css"/>  <!--[if IE]><link type="text/css" rel="stylesheet" href="/css/right_ie.css"/><![endif]--></head>

Thanks, I'll try that, will it work for IE7 and 6? And is it possible to have a seperate css load for both 6 and 7?
Link to comment
Share on other sites

Thanks, I'll try that, will it work for IE7 and 6? And is it possible to have a seperate css load for both 6 and 7?
This is going to sound really strange, but I tried your suggestion and it worked, BUT it only worked when I made a spelling mistake. So if I get the link correctly then it doesn't work and vice versa if I get the link wrong them it works.This is WRONG but does works:
<link type="text/css" rel="stylesheet" href="/css/right.css"/>  <!--[if IE]><link type="text/css" rel="stylesheet" href="/css/right_ie.css"/><![endif]-->

This is RIGHT but doesn't work

<link type="text/css" rel="stylesheet" href="/css/web/right.css"/>  <!--[if IE]><link type="text/css" rel="stylesheet" href="/css/web/right_ie.css"/><![endif]-->

All of the other css files work, it's just this one that doesn't

Link to comment
Share on other sites

not sure how you have your app structured but I just used the paths in the code you posted before. Maybe try clearing your cache?
I think it may be a server problem because the link used to work, I'll get onto the host about it.Thanks for your help, I'll definitely use your suggestion when the host sorts out the path
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...