Jump to content

Block IE 10 and under on my website.


Hazukiy
 Share

Go to solution Solved by Irate,

Recommended Posts

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>

 

 

Link to comment
Share on other sites

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 by ignace
Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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]-->
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Solution

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 by Irate
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.