Reputation: 495
My programmer is on vacation so I need your help! I discovered a page that has a bug for IE users. I want to redirect all IE users to a different page.
How can I do this? I searched all through Google and Stackoverflow and cannot find an answer. (I found some scripts, and tried them, but none worked).
Upvotes: 18
Views: 42294
Reputation: 1
js code:
<script>if (/*@cc_on!@*/false || (!!window.MSInputMethodContext && !!document.documentMode)){window.location.href="https://....html";}</script>
You can also use this Boycott-IE:upgrade-your-browser
Upvotes: 0
Reputation: 1387
Support for conditional comments has been removed in Internet Explorer 10 standards
I'm use this dirty hack for redirecting IE10+ users
<script type="text/javascript">
var check = true;
</script>
<!--[if lte IE 9]>
<script type="text/javascript">
var check = false;
</script>
<![endif]-->
<script type="text/javascript">
if (check) {
window.location = "page_for_ie10+.html";
}
</script>
Upvotes: 0
Reputation: 411
I put this in header and it works for all IE versions:
<!-- For IE <= 9 -->
<!--[if IE]>
<script type="text/javascript">
window.location = "https://google.com";
</script>
<![endif]-->
<!-- For IE > 9 -->
<script type="text/javascript">
if (window.navigator.msPointerEnabled) {
window.location = "https://google.com";
}
</script>
Upvotes: 7
Reputation: 71
A reminder that the [if IE] solution does not apply to IE 10 or greater. This can be very annoying for "features" that have not been fixed by IE 10. I am going to try the php and java solutions and re-comment.
Upvotes: 7
Reputation: 5658
For Internet Explorer 10 this one works well
<script type="text/javascript">
if (navigator.appName == 'Microsoft Internet Explorer')
{
self.location = "http://www.itmaestro.in"
}
</script>
Upvotes: 3
Reputation: 14477
Server-side solution using PHP that's guaranteed to work on all browsers:
<?
if ( preg_match("/MSIE/",$_SERVER['HTTP_USER_AGENT']) )
header("Location: indexIE.html");
else
header("Location: indexNonIE.html");
exit;
?>
Upvotes: 2
Reputation: 5068
Or, a non-JS solution, put the following in your head
section:
<!--[if IE]>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.google.com">
<![endif]-->
Upvotes: 37
Reputation: 11552
Try:
<!--[if IE]>
<script type="text/javascript">
window.location = "http://www.google.com/";
</script>
<![endif]-->
Upvotes: 48