user3229248
user3229248

Reputation: 23

Disable HTML content for IE users

I'm wanting to create (or use existing) code that will disable a pages content for IE users.

This HTML page should only be available to Google Chrome and Firefox users.

Any ideas on where I should start at, or if you know of any code like this that already exists? I'm a novice to programming and need a headstart, but I'm willing to program my own code if someone can push me in the right direction.

Upvotes: 1

Views: 202

Answers (4)

Funk Forty Niner
Funk Forty Niner

Reputation: 74217

If you can use .htaccess on your server, you can use this server-side (redirection) method.

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$ [NC]
RewriteRule .* ie.php
# RewriteRule .* http://www.example.com/ie.php

Upvotes: 0

bboysupaman
bboysupaman

Reputation: 1334

Try adding this to your head section:

<!--[if IE]>
    <link rel="stylesheet" type="text/css" href="ie-styles.css" />
<![endif]-->

Then in that stylesheet make it:

body {
display: none;
}

Additionally, add the following code to your <head> to ensure that later versions of IE will read the conditional comments.

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">

Upvotes: 2

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167172

Without the CSS or JavaScript, I guess this is the best solution.

<!--[if !IE]-->
    <body>
        ...
        ...
        ...
    </body>
<!--[endif]-->

Surround the <body> tags with IF !IE conditional comments.

Upvotes: 0

Flavio
Flavio

Reputation: 398

You can try with jQuery

$(document).ready(function({
   jQuery.each( jQuery.browser, function( i, val ) {
         if ( $.browser.webkit || $.browser.mozilla ) {
           alert( "Render HTML!" );
         }
   });
}));

Or with PHP function get_browser() http://www.php.net/get_browser

Upvotes: 0

Related Questions