validation - 如何处理未在 HTML5 中验证的元元素?

标签 validation .htaccess html meta-tags

在 HTML5 中,一些元元素不验证(还?)像:

<meta http-equiv="x-ua-compatible" content="ie=emulateie7;chrome=1">
<meta http-equiv="imagetoolbar" content="no">

条件注释是这里的适当解决方案吗?元元素仍会按预期工作吗?

<!--[if IE]><meta http-equiv="x-ua-compatible" content="ie=emulateie7;chrome=1"><![endif]-->
<!--[if lt IE 7]><meta http-equiv="imagetoolbar" content="no"><![endif]-->

使用 .htaccess 文件而不是元元素(不幸的是,并不总是可行),这是正确的方法吗?

<IfModule mod_setenvif.c>
  <IfModule mod_headers.c>
  # BrowserMatch MSIE ie OR?
    BrowserMatch MSIE emulate_ie7
  # Header set X-UA-Compatible "IE=EmulateIE7" env=ie OR?
    Header set X-UA-Compatible "IE=EmulateIE7" env=emulate_ie7
    BrowserMatch chromeframe gcf
    Header append X-UA-Compatible "chrome=1" env=gcf
  </IfModule>
</IfModule>

谢谢!

最佳答案

就“x-ua-compatible”标签而言,我选择了 .htaccess 指令。我关注了html5boilerplate模板:

# ----------------------------------------------------------------------
# Better website experience for IE users
# ----------------------------------------------------------------------

# Force the latest IE version, in various cases when it may fall back to IE7 mode
#  github.com/rails/rails/commit/123eb25#commitcomment-118920
# Use ChromeFrame if it's installed for a better experience for the poor IE folk

<IfModule mod_setenvif.c>
  <IfModule mod_headers.c>
    BrowserMatch MSIE ie
    Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
  </IfModule>
</IfModule>

<IfModule mod_headers.c>
# Because X-UA-Compatible isn't sent to non-IE (to save header bytes),
#   We need to inform proxies that content changes based on UA
  Header append Vary User-Agent
# Cache control is set only if mod_headers is enabled, so that's unncessary to declare
</IfModule>

关于validation - 如何处理未在 HTML5 中验证的元元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3489758/

相关文章:

regex - htaccess 正在重写整个 URL 并保留子目录

html - 为什么在 django 中使用 xhtml2pdf 呈现为 pdf 时,html 表中的某些列会崩溃?

html - Virtualbox 访问共享文件夹上的 HTML 文件

javascript - 使用 jQuery 的 animate with css 过滤器。

Spring WebFlow : view-state is not calling validation method before <evaluate> tag

php - Laravel 验证 : soft delete + unique email + update

asp.net-mvc - Timepicker 字段必须是日期 - 验证失败

.htaccess - 让我们加密 SSL 导致 Chrome 出现问题

.htaccess - nginX 中的 URL 重写

javascript - jQuery: 使用 `jquery-validation` 的远程验证后无法提交表单