[英]Disable HTML content for IE users
I'm wanting to create (or use existing) code that will disable a pages content for IE users. 我想创建(或使用现有的)代码来为IE用户禁用页面内容。
This HTML page should only be available to Google Chrome and Firefox users. 该HTML页面仅对Google Chrome和Firefox用户可用。
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.
我是编程的新手,需要抢先一步,但是如果有人可以向正确的方向推动我,我愿意编写自己的代码。
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. 此外,将以下代码添加到您的
<head>
以确保更高版本的IE将读取条件注释。
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
You can try with jQuery 您可以尝试使用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 或使用PHP函数get_browser() http://www.php.net/get_browser
Without the CSS or JavaScript, I guess this is the best solution. 如果没有CSS或JavaScript,我想这是最好的解决方案。
<!--[if !IE]-->
<body>
...
...
...
</body>
<!--[endif]-->
Surround the <body>
tags with IF !IE
conditional comments. 在
<body>
标签周围加上IF !IE
条件注释。
If you can use .htaccess
on your server, you can use this server-side
(redirection) method. 如果可以在服务器上使用
.htaccess
,则可以使用此server-side
(重定向)方法。
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$ [NC]
RewriteRule .* ie.php
# RewriteRule .* http://www.example.com/ie.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.