2013-03-05 46 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。

相關問題