Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14

Thread: Detect browser

  1. #1
    Regular Coder
    Join Date
    Apr 2008
    Posts
    257
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Detect browser

    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!
    Watch out for MMA Jump

  • #2
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by Nblufire12 View Post
    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).
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #3
    Regular Coder
    Join Date
    Apr 2008
    Posts
    257
    Thanks
    15
    Thanked 0 Times in 0 Posts
    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
    Watch out for MMA Jump

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    This has a ten second delay:
    Code:
    <!--[if (IE 6)|(IE 7)]>
    <meta http-equiv="refresh" content="10;url=IE6_7.htm" />
    <![endif]-->

  • #5
    Regular Coder
    Join Date
    Apr 2008
    Posts
    257
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Oh **** that's brilliant!!!

    Thank you sir
    Watch out for MMA Jump

  • #6
    Regular Coder
    Join Date
    Apr 2008
    Posts
    257
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Does this go in between

    Code:
    <!--[if (IE 6)|(IE 7)]>
    <meta http-equiv="refresh" content="10;url=IE6_7.htm" />
    <![endif]-->
    <head>
    and
    </head>
    Watch out for MMA Jump

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    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.

  • #8
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by Nblufire12 View Post
    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):

    Code:
    <!--[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

    Edit:
    Guess I was slow out of the gate huh?
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #9
    Regular Coder
    Join Date
    Apr 2008
    Posts
    257
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Krupski View Post
    For MSIE specific detection, you can use the following (and it works with or without Javascript):

    Code:
    <!--[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
    Watch out for MMA Jump

  • #10
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by Nblufire12 View Post
    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!

    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #11
    Regular Coder
    Join Date
    Apr 2008
    Posts
    257
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Krupski View Post
    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!

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

  • #12
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by Nblufire12 View Post
    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
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #13
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    Quote Originally Posted by Krupski View Post
    For MSIE specific detection, you can use the following (and it works with or without Javascript):

    Code:
    <!--[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

    Edit:
    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.

  • #14
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    Quote Originally Posted by Krupski View Post
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •