PDA

View Full Version : <!--[if not IE]>


JAVAEOC
12-11-2003, 11:26 PM
how do i write it if it is not IE

like this?

<!--[ifnotIE]--> ?

lavalamp
12-12-2003, 12:38 AM
Does this do the job:

if(navigator.appName.toLowerCase().indexOf("micro")<0 || navigator.appName.toLowerCase().indexOf("ie")<0){

// Code in here.

}

fredmv
12-12-2003, 01:17 AM
Originally posted by lavalamp
if(navigator.appName.toLowerCase().indexOf("micro")<0 || navigator.appName.toLowerCase().indexOf("ie")<0){

// Code in here.

} That wouldn't work correctly. The best way to check for IE is:<script type="text/javascript">
//<![CDATA[
if(typeof clientInformation == 'undefined') alert('Not running IE.');
//]]>
</script>

lavalamp
12-12-2003, 01:20 AM
I'm interested as to why it wouldn't work properly, could you please fill me in on that. I would have used some sort of IE only thing (as I believe you have done) but, amazing as it may seem, I couldn't think of one at the time.

jkd
12-12-2003, 01:54 AM
<![if ! IE]>
Not using IE
<![endif]>

glenngv
12-12-2003, 02:25 AM
more details about Conditional Comments of IE (http://www.javascriptkit.com/howto/cc.shtml)

brothercake
12-12-2003, 04:30 AM
Note that inverse comments don't work properly in IE5.0 for Win2K - it won't output what's inside it, but it will output the "<![if ! IE]>" as literal text.

You can solve that by putting the object inside an element with the same color and background color.

JAVAEOC
12-12-2003, 01:06 PM
so if all this stuff isnt any good: <--if[IE]-->

then how do i write that in a good way?


i know the way for not ie but not for IE... :confused:


//<![CDATA[
if(typeof clientInformation == 'undefined') alert('Not running IE.');
//]]>


with what do i have to replace 'undefined'?

brothercake
12-12-2003, 10:09 PM
I didn't say it wasn't any good - only a warning that it degrades dubiously in one specific, and very old, build of IE5.

Check out the conditional comments article - it has information on positive and negative IE conditions.

Beyond those, you can use javascript to distiniguish IE from other browsers, or you can use CSS selectors. Here, for example, is a CSS selector that only works in IE (because it's invalid)

* html foo.bar { ... }

While here's one which works in everything except IE (because it's CSS2)

foo[class="bar"] { ... }

JAVAEOC
12-13-2003, 03:04 AM
i have discovered that neither of the codes any of you gave me work coractly....

Opra seems to be IE (which it is not by the way)

Mozilla seems to be NS (which it is not by the way)

JAVAEOC
12-13-2003, 03:07 AM
here this link is supposed to detect your browser settings....


it doesnt

http://www.w3schools.com/js/tryit.asp?filename=tryjs_browserdetails

brothercake
12-13-2003, 04:47 AM
Well most browser sniffers detect Netscape with "mozilla" in the UA string, which is always going to match mozilla. What you could do is sniff for "gecko" and the absence of "netscape".

But really UA-based browser detection is fundamentally unreliable. It's better to ascribe browser variables by doing object and feature detection, like the "typeof clientInformation" test earlier.

Opera, for example, can spoof as Internet Explorer; with the right extensions both Safari and Mozilla can spoof as pretty much anything. But in all those cases, the objects and properties they support remain the same*, which is why that kind of testing is more reliable.

Have a look at this, where I take that approach - http://www.brothercake.com/scripts/sniffer.php - it's not completely free of UA information, but mostly.


* almost - Opera actually supports document.all in IE spoof mode, but nobody uses document.all anymore, right ;)

Paul Jr
12-13-2003, 04:48 AM
That's probably because it's set to Identify as I.E. 6.

Open up Opera, click on "File" and go down to "Quick Preferences." Look at the bottom of the submenu, and see if "Identify as Opera" is checked; if not, check it.

Or just hit Ctrl+Alt+O

brothercake
12-13-2003, 04:49 AM
Oh, and JAVAEOC - can you please be a bit more polite. I'm coming across a number of threads where your tone is rather terse, verging on aggressive. Remember that nobody is obliged to help you.

Ta :)

brothercake
12-13-2003, 04:52 AM
Originally posted by Paul Jr
Open up Opera, click on "File" and go down to "Quick Preferences." Look at the bottom of the submenu, and see if "Identify as Opera" is checked; if not, check it.
Sure you can do that for yourself, but not for other people - when you're scripting to allow for browser spoofing, it's other people's settings that matter, and they'll be unknown

Paul Jr
12-13-2003, 04:55 AM
Oooh... sorry 'bout that. I thought he was just talking about himself.

JAVAEOC
12-13-2003, 02:10 PM
sorry if i have been rude... I will try to chage this...

thx for all your help....

I think Im still going to stick with the <--if IE stuff
cause the rest is way over my head :)