Hello, I am looking for the best way to redirect the user to a different site, if they are using a version of Internet Explorer under 7. What would be the best way to do this? Thanks
Use internet explorer conditional statements like <--[if ie7]--> code <--endif--> or some crap only IE can read this code, everything else thinks it's a comment and ignores it do a google and MS will tell you more
Yeah, the IE conditional comments work best, but then you have to use a client-side redirect... Oh well Here's your code: <!--[if lt IE 7]> <script type="text/javascript"> window.location = "http://www.your-redirect-url.com"; </script> <p>If you are not automatically redirected, please <a href="http://www.your-redirect-url.com">click here</a>.</p> <![endif]--> Code (markup):
Many thanks for that! I was wondering, which is better, that JavaScrip or this PHP: $vernum=array(); $regex = '/MSIE ([0-9]+)\..+;/'; preg_match($regex,$_SERVER['HTTP_USER_AGENT'],$ver); if (count($ver) < 2) { // not IE at all } else { // IE if ($ver[1] < 7) { // version < 7 so redirect header('Location: http://www.example.com/'); exit; } else { // version >= 7 } } Code (markup): Thanks again
PHP would be a better option, since some people might have javascript turned off. I'm not sure wether you can turn it off in IE though since I'm not using it.. ? :S
And .Net trumps all Javascript is limited to those that have javascript turned on but this is the vast majority - be careful of stats that you find on this as bots/ spiders typically dont support javascript and so will skew the numbers as the true figure you want for this project is the number of IE7 users with javascript enabled. As per the previous query you posted on this though, look at the reason as to why you are redirecting. If it is to fix layout issues then it is much better to actually fix the base problem than trying to maintain 2 versions of a site (or at worst dynamically set the layout template by browser rather than redirect to a duplicate of the site)
First off, and don't take offense at what I'm about to say, if you need to direct an IE user who's not using Internet Explorer 7 to a different page, you're doing something wrong. Now that that's out of the way, what does your "problem page" look like (I'm asking because I'm fairly certain you have one)?
Agreed - most likely. Browser sniffing on that level usually indicates some layout element or other feature which pretty much means you are doing something wrong in the first place. What he said.
Not necessarily, it could be a "want to" rather than "need to" - could be page 1 slags IE 7 off calling anyone who has installed it idiots and page 2 says how great IE 7 is and how the world is now your oyster and they only want people to see the relevant message (unlikely but you get the principle) As per my post though, agree if it is a layout issue then the problem should be fixed and not a redirect used.
In which case you're doing something wrong - and that's by starting with what you want people to use, not what they want to use. Respect the user's preference - or predicament, and give them the content they were seeking in the first place.