...

View Full Version : Detect browser



Nblufire12
07-15-2011, 10:25 PM
hey all

is there a code where I can detect if the browser is IE6 or IE7 and send them to another webpage?

my current design is not compatible with IE6 or 7 and i want to make a new page that's compatible.


thanks!

Krupski
07-15-2011, 10:36 PM
hey all

is there a code where I can detect if the browser is IE6 or IE7 and send them to another webpage?

my current design is not compatible with IE6 or 7 and i want to make a new page that's compatible.

thanks!

Browser detection is a bad idea. You should (if you feel the need to) detect features and functions that you want to use rather than looking for a certain browser.

If your goal is specifically to tell people "hey moron use a REAL browser", don't waste your time. They won't get it. If they did, they would already be using a W3C compliant browser.

On the realistic side... MSIE detection is easy. If an accepted standard that works on any browser doesn't work, chances are virtually 100% that you're dealing with Microsoft Internet Destroyer (um I mean Explorer).

Nblufire12
07-15-2011, 10:49 PM
I think IE6 and IE7 are the only browsers that cant view our site correctly.

Can you show me an example of how I could detect if they are IE6 or 7 and send them to ourwebsite.com/anotherpage?

thanks

jalarie
07-15-2011, 10:58 PM
This has a ten second delay:


<!--[if (IE 6)|(IE 7)]>
<meta http-equiv="refresh" content="10;url=IE6_7.htm" />
<![endif]-->

Nblufire12
07-15-2011, 11:01 PM
Oh **** that's brilliant!!!

Thank you sir

Nblufire12
07-15-2011, 11:04 PM
Does this go in between


<!--[if (IE 6)|(IE 7)]>
<meta http-equiv="refresh" content="10;url=IE6_7.htm" />
<![endif]-->

<head>
and
</head>

jalarie
07-15-2011, 11:09 PM
Yes, it goes in the head section.

Your users would probably like a warning that something is happening, so add a script and alert to say so.

Some people like to change the "10" to "0" so that it goes immediately. This can be VERY confusing, especially to visually-impaired users, and it breaks the BACK button.

Krupski
07-15-2011, 11:12 PM
I think IE6 and IE7 are the only browsers that cant view our site correctly.

Can you show me an example of how I could detect if they are IE6 or 7 and send them to ourwebsite.com/anotherpage?

thanks

For MSIE specific detection, you can use the following (and it works with or without Javascript):



<!--[if lte IE 7]>
<p>You are using MSIE 7 or below</p>
<![endif]-->
That conditional code says "IF MSIE version is less than or equal to 7 THEN display the message. ENDIF"

Put whatever you want in place of the <p>.....</p>.

Hope this helps.

-- Roger


Guess I was slow out of the gate huh? :)

Nblufire12
07-15-2011, 11:13 PM
For MSIE specific detection, you can use the following (and it works with or without Javascript):



<!--[if lte IE 7]>
<p>You are using MSIE 7 or below</p>
<![endif]-->
That conditional code says "IF MSIE version is less than or equal to 7 THEN display the message. ENDIF"

Put whatever you want in place of the <p>.....</p>.

Hope this helps.

-- Roger

I could use the <p> But I'd rather design a new page for people with IE6 or 7 saying for them to upgrade

thanks

Krupski
07-15-2011, 11:16 PM
I could use the <p> But I'd rather design a new page for people with IE6 or 7 saying for them to upgrade

thanks

I put the <p> line in there as an example "this happens if...".

Of course, the people above who posted the META refresh code gave you a better answer since they also told you how to go to a different web page where I did not.

In my opinion... I really like that you are doing this. I spend a large percentage of my time taking perfectly good code and butchering it to "also" support MSIE.

If everyone did what you are doing, MSIE would go away and the world would be happier!

:thumbsup:

Nblufire12
07-15-2011, 11:18 PM
I put the <p> line in there as an example "this happens if...".

Of course, the people above who posted the META refresh code gave you a better answer since they also told you how to go to a different web page where I did not.

In my opinion... I really like that you are doing this. I spend a large percentage of my time taking perfectly good code and butchering it to "also" support MSIE.

If everyone did what you are doing, MSIE would go away and the world would be happier!

:thumbsup:

Haha ok cool! I didn't know IE was so hated, its just that my site looks like garbage in IE6 and 7...

Krupski
07-15-2011, 11:26 PM
Haha ok cool! I didn't know IE was so hated, its just that my site looks like garbage in IE6 and 7...

MSIE is "hated" by web designers. Users simply don't know any better.

I dread when I write some code which works beautifully in Firefox and all the other browsers... then I have to do the MSIE test which invariably fails (or the layout doesn't work).

Browser users can't be blamed, because they don't know any better. MSIE came with their computer and it "gets on the web".

Web designers are almost forced to support MSIE with extra, non-standard code because otherwise they would lose a sizable percentage of viewers/users.

It's a vicious circle and the only way to break it is to boldly come out and say "This website works on any standards compliant browser, so ditch MSIE and get with the program!"

Not many web designers have the courage to do that! ;)

-- Roger

jalarie
07-15-2011, 11:59 PM
For MSIE specific detection, you can use the following (and it works with or without Javascript):



<!--[if lte IE 7]>
<p>You are using MSIE 7 or below</p>
<![endif]-->
That conditional code says "IF MSIE version is less than or equal to 7 THEN display the message. ENDIF"

Put whatever you want in place of the <p>.....</p>.

Hope this helps.

-- Roger


Guess I was slow out of the gate huh? :)


That does display the message without using JavaScript, but it does not auto-forward to the proper page. And that code has to be in the body section of the page. And the OP specifically requested only IE6 and IE7, not everything less than or equal to IE7.

jalarie
07-16-2011, 12:03 AM
It's a vicious circle and the only way to break it is to boldly come out and say "This website works on any standards compliant browser, so ditch MSIE and get with the program!"

Not many web designers have the courage to do that! ;)

-- Roger
Amen to that!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum