August 6, 201214 yr Hi, I want to detect ie7 and ie8 users, then include ie_header.php if the user is on that browser, or just heaer.php if its any other browser; I was advised on this code, but not getting a response on the post. if($_SERVER['HTTP_USER_AGENT'] == 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)') include 'Includes/Header.php'; else { include 'Includes/IE_Header.php'; }; Any help would be greatly appreciated as im having some rather dreadful compatiblity errors in ie7 and 8 with some plugins that im using. Thanks in advance. Craig
August 6, 201214 yr To be honest, this seems to be going around it the wrong way. You could easily achieve the same thing using HTML conditional comments. Here are a few examples http://www.positioniseverything.net/articles/cc-plus.html
August 6, 201214 yr Author thanks for the reply. I have tried with the html but for some reason it ruins the design completely. puts everything out of place. I think this is the right route, i just need to understand why its not working. Thanks
August 7, 201214 yr To be honest I don't know why the content specifically has to be completely different. Is there major changes that you want people with <IE8 to see / not see? I think modern standards and designs encourage us to have the same content regardless of the browser with different styles applied to different type of browsers. But with the code I posted above you need to get the exact user agent string.. use this: http://www.enhanceie.com/ua.aspx Also your if statement needs braces after the if() and before the else
August 7, 201214 yr Author ive validated the site and it and no errors came up, it has to be different because the plugins are interfering with each other on ie 7 and 8
August 16, 201214 yr Have you considered using Regular Expressions to match the User Agent rather than just an equality check on a string? Either that or use full device detection software.
Create an account or sign in to comment