2013-03-05 44 views
0

我习惯于Wordpress自动添加IE特定的ID属性到HTML标记来编写Internet Explorer特定的CSS类。我刚刚注意到,当我在IE9中查看该网站时,此功能目前不工作。为什么Wordpress不能为Internet Explorer 9分配<html id =“ei9”...?

在IE8 ...

<html id="ie8" lang="en-US"> 

在IE9中......

<html lang="en-US"> 

这是预期的行为? 有谁知道这是为什么?

+0

如果你只是直接发布了什么是你在IE9中的bug,它对所有人都会更有用:-) – 2013-03-05 15:50:15

+0

我很高兴你想要帮助,但这是一个非常不同的问题。 – emersonthis 2013-03-05 15:52:03

+0

允许我,如果你不知道如何找到你的主题中的html条件,那么我不认为你有很多的机会来解决IE9的任何错误:-) – 2013-03-05 16:03:30

回答

2

也许这样的事情已经在你的WordPress的主题定义:

<!--[if IE 6]> <html id="ie6" <?php language_attributes(); ?>> <![endif]--> 
<!--[if IE 7]> <html id="ie7" <?php language_attributes(); ?>> <![endif]--> 
<!--[if IE 8]> <html id="ie8" <?php language_attributes(); ?>> <![endif]--> 
<!--[if !(IE 6) | !(IE 7) | !(IE 8)]><!--> <html <?php language_attributes(); ?>> <!--<![endif]--> 

这些conditional comments将IE读取,并且将ID添加到HTML。这可能是为了加载一些CSS,或者只针对该版本的IE。

如果你愿意,你可以这样写:

<!--[if IE 9]> <html id="ie9"> <![endif]--> 

而且里面添加一些IE9具体的东西。

+0

合理。我会看看。 – emersonthis 2013-03-05 15:50:08

+0

宾果!它是针对主题的。出于某种原因,我认为该功能是由WP核心通过过滤器或其他东西添加的。不知道为什么我跳到这个结论。 – emersonthis 2013-03-05 15:55:28

1

可能因为IE8和之前都有怪异的怪癖,需要黑客绕过,IE9是相对体面的,所以它可能不需要为它添加额外的定义。

+0

我担心可能是这样。这真是太糟糕了,因为IE9肯定不是没有它的怪癖。 – emersonthis 2013-03-05 15:48:05

+0

@Emerson,你可以看看Modernizr(http://modernizr.com/)来帮助处理浏览器的不兼容问题。 – dnagirl 2013-03-05 15:50:09

0

可能是因为IE9被认为是解决了过去困扰WordPress的很多问题的里程碑。

如果您仍然想这种功能,为什么不使用条件注释,像这样:

<!DOCTYPE html> 
<!--[if lt IE 7 ]><html class="ie ie6" <?php language_attributes(); ?>> <![endif]--> 
<!--[if IE 7 ]><html class="ie ie7" <?php language_attributes(); ?>> <![endif]--> 
<!--[if IE 8 ]><html class="ie ie8" <?php language_attributes(); ?>> <![endif]--> 
<!--[if (gte IE 9)|!(IE)]><!--><html <?php language_attributes(); ?>> <!--<![endif]--> 
<head> 
</head> 
<body> 
</body> 
</html> 

的效果好很多吧?这当然会进入你主题的header.php

希望有帮助, Mikey。

相关问题