Hazukiy Posted December 2, 2013 Share Posted December 2, 2013 Hi, I'm creating a website for my college course as part of an assignment. Blocking IE isn't part of the assignment but my CSS document has percentages and for some reason the college uses a really old IE version so it completely messes up the website. What I was hoping to do is make it so all versions under and equal to 10 are blocked; IE 11 works well with my website. So overall I need a method of blocking IE version 10 and under without using PHP or .HTACCESS. What I need it to do is when the person requests the website with IE 10 and under that it returns a document named "reject.html" otherwise have it return index.html. I've done something like this last year with javascript but for some reason it's not working now? Please note that this isn't going to be a full blown website it's just a 3 page website but in order for the lectures to mark it correctly it must be on the correct browser. Help will be much appreciated. Here are the methods that I've tried so far. <script> /*@cc_on @if (@_jscript_version > 10) document.location.href = "reject.html"; @elif (@_jscript_version == 10) document.location.href = "index.html"; @elif (@_jscript_version == 9) document.location.href = "reject.html"; @elif (@_jscript_version == 5. document.location.href = "reject.html"; @elif (@_jscript_version == 5.7 && window.XMLHttpRequest) document.location.href = "reject.html"; @elif (@_jscript_version == 5.6 || (@_jscript_version == 5.7 && !window.XMLHttpRequest)) document.location.href = "reject.html"; @elif (@_jscript_version == 5.5) document.location.href = "reject.html"; @elif (@_jscript_version < 5.5) document.location.href = "reject.html"; @else document.location.href = "index.html"; @end @*/ </script> And <script language="javascript"> <!-- if (navigator.appName == "Microsoft Internet Explorer") { document.location = "reject.html"; } // --> </script> Quote Link to comment Share on other sites More sharing options...
ignace Posted December 2, 2013 Share Posted December 2, 2013 (edited) LOL. You don't reject a browser simply because it doesn't properly renders your website. These are not the dark ages of webdevelopment where it was common to give a preference for a specific browser and version. Your website should display properly in IE8+, Chrome, Firefox, Safari, etc.. If it doesn't you need to change your CSS. Edited December 2, 2013 by ignace Quote Link to comment Share on other sites More sharing options...
Hazukiy Posted December 2, 2013 Author Share Posted December 2, 2013 LOL. You don't reject a browser simply because it doesn't properly renders your website. These are not the dark ages of webdevelopment where it was common to give a preference for a specific browser and version. Your website should display properly in IE8+, Chrome, Firefox, Safari, etc.. If it doesn't you need to change your CSS. And as I stated this is a 3 page website and the IE version that the college has doesn't seem to like percentages in widths and height which I use, weather it's an effective method or not I'm just wondering if there's a way to BLOCK users from being able to access the website with the application Internet Explorer. And please note this is an assignment which means I don't have time to write another CSS document just so it can run in a browser that I don't even use. Quote Link to comment Share on other sites More sharing options...
Irate Posted December 2, 2013 Share Posted December 2, 2013 No need for CCs. <!--[if IE]><style>/* this style will only be loaded for IE */</style><![endif]--> Quote Link to comment Share on other sites More sharing options...
Hazukiy Posted December 2, 2013 Author Share Posted December 2, 2013 No need for CCs. <!--[if IE]><style>/* this style will only be loaded for IE */</style><![endif]--> O nice but could I have a script inside of that instead that would redirect a person to another html document? Using the document.location.href method? Quote Link to comment Share on other sites More sharing options...
Irate Posted December 3, 2013 Share Posted December 3, 2013 Of course... There's a way to do that just with HTML, too (but it's disfavoured by the W3C, so use something else than HTML if you). <!--[if lte IE 8]><meta http-equiv="refresh" content="0; http://urlhere.com/file.htm"><![endif]-->And the version with JS. <!--[if lte IE 8]><script>window.location="http://urlhere.com/file.htm";</script><![endif]--> Quote Link to comment Share on other sites More sharing options...
Hazukiy Posted December 3, 2013 Author Share Posted December 3, 2013 Of course... There's a way to do that just with HTML, too (but it's disfavoured by the W3C, so use something else than HTML if you). <!--[if lte IE 8]><meta http-equiv="refresh" content="0; http://urlhere.com/file.htm"><![endif]-->And the version with JS. <!--[if lte IE 8]><script>window.location="http://urlhere.com/file.htm";</script><![endif]--> Thanks, I don't know if it worked as I changed it to IE 11 (The IE version I have) and it didn't seem to work but I've added it anyway. Quote Link to comment Share on other sites More sharing options...
Solution Irate Posted December 4, 2013 Solution Share Posted December 4, 2013 (edited) The HTML comment works for all IE versions which are lte 8, where lte is "less than or equal". If you need a more general condition, use <!--[if IE]>...<![endif]-->. Other possible variants are lt IE n (where n is the version number), gt IE n, gte IE n and !IE (for NOT IE). Edit: Got my BBCode wrong. Edited December 4, 2013 by Irate Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted December 8, 2013 Share Posted December 8, 2013 Internet Explorer can render older versions of itself Open IE, click F12 or in the menu do Tools -> F12 Developer Tools Up top will see Browser Modes, select a different one. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.