4

I am using ruby on rails 3 for my site and am almost finished, the site is due to go live very soon (Monday) but I am having problems with IE7 compatability, so as a temporary measure I would like to have users redirected to a "404" esque page if they are using IE7, it will just have some basic info stating to try another browser for now until the issues are fixed

How would i go about this in rails 3? Has anyone done anything like this in the past? I dont want to get into the should I/shouldnt I support IE7, I am going to, just going to take a little longer than I thought

Any help on this appreciated

1
  • Thank you to all who provided answered, all very useful Commented Jul 19, 2012 at 14:38

4 Answers 4

13

You could do a script to redirect:

<!--[if IE 7]> <script type="text/javascript"> window.location = "http://www.google.com/"; </script> <![endif]--> 

Or a html:

<!--[if IE 7]> <meta http-equiv="REFRESH" content="0;url=http://www.google.com/"> <![endif]--> 

Or simply leave a message saying that this site don't support

Sign up to request clarification or add additional context in comments.

Comments

2

If you are able to use jQuery, you can do a simple browser version test and then redirect to the appropriate page and set a cookie:

 //IE 7 browser detection if ($.browser.msie) { var version = $.browser.version; if (version == '7.0') { var cookie = $.cookie('IE7'); if (cookie != 'set') { $.cookie('IE7', 'set'); window.location = '404-url-string'; } window.location = '404-url-string'; } } 

you will need to bring in the jquery cookie plugin as well to set the cookie. The '404-url-string' would be the pathname of the page you are directing to.

Comments

1

As a temporary measure, would a IE conditional with a Javascript redirect work?

 <!--[if IE 7]> <script type="text/javascript"> window.location = "/upgrade_browser.html"; </script> <![endif]--> 

Source: Javascript redirect for Internet Explorer browser version user agent?

9 Comments

would this go in my app/layouts file like the rest of my stylesheets/javascripts? thanks for your answer by the way
Not a problem. No, this would go in your application.html.erb file. The main if loop only shows for IE browsers, so you could practically place it anywhere in the file, but I would advise to place it before the </body> tag.
Not a problem. Make sure to change the window.location path to the page you would like it to redirect to.
ok so i have placed the above code in application.html.erb file and its all commented out (due to the <!-- im guessing, so when i go to ie7 there is no redirect? any ideas on this one, sorry to be a pain
Are you using Internet Explorer 7, or use FF/Chrome and change your User agent? Don't worry about it.
|
1

Little bit of javascript should take care of this one.

Here's a little demo of the JavaScript navigator object:

<script type="text/javascript"> txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>"; txt+= "<p>Browser Name: " + navigator.appName + "</p>"; txt+= "<p>Browser Version: " + navigator.appVersion + "</p>"; txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>"; txt+= "<p>Platform: " + navigator.platform + "</p>"; txt+= "<p>User-agent header: " + navigator.userAgent + "</p>"; document.getElementById("example").innerHTML=txt; </script> 

Note that this is literally taken straight from W3Schools (which I normally do not recommend, but for this issue it's fine)

Anyway, you're gonna want something like:

<script type="text/javascript"> if(navigator.appName=="Internet Explorer" && navigator.appVersion == "7.0.Whatever") //maybe its "IE", I didn't actually check. Sorry lol, don't have time to test this out { window.location.href = "YourErrorPageFileName"; } </script> 

Throw that code in your login page (or master page, whatever), and you should be good to go.

Side note: no idea why the code is formatting all dumb like that. Guess StackOverflow is parses slashes weirdly under certain conditions

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.