2012-07-09 65 views
1

我收到錯誤:X-UA兼容META標籤('IE = 7')被忽略,因爲文檔模式已經完成。HTML X-UA兼容標籤在IE中不起作用9

我讀過這個問題的解決方法是元標記在頭標記中沒有被聲明爲足夠高,但是我試過將這個元標記移動到頭標記的第一行並且沒有修復錯誤。

我在Grails .gsp文件中工作,該文件也使用了敲除js。

下面是相關的代碼:

<!doctype html> 
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> 
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> 
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> 
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> 
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"><!--<![endif]--> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>myInfinitec Membership Management</title> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
     <link rel="shortcut icon" href="/ucpmanagementportal/static/images/favicon.ico" type="image/x-icon"> 

    <meta name="layout" content="main"/> 




     <script src="/ucpmanagementportal/static/plugins/jquery-1.7.1/js/jquery/jquery-1.7.1.min.js" type="text/javascript" ></script> 
<link href="/ucpmanagementportal/static/bundle-bundle_coreCSS_head.css" type="text/css" rel="stylesheet" media="screen, projection" /> 



    </head> 

編輯:在IE顯影劑窗口有每行之間產生「文本 - 空文本節點」行。也許這就是X-UA兼容元標記之前的東西。我讀到修復的方法是在受影響的元素上添加display:block和zoom:1,但這不起作用。以下是對我描述一個例子:

<head> 
Text - Empty Text Node 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
Text - Empty Text Node 
<meta style="display: block; zoom: 1;" http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> 
Text - Empty Text Node 
+0

您的x-ua兼容屬性設置爲邊緣? – StuartLC 2012-07-09 16:04:15

+0

應該設置什麼呢? – 2012-07-09 16:06:45

+0

如果我理解你的問題,你想要IE 7兼容性,那麼它會是IE = 7,鉻= 1。可能還有其他x-ua兼容的介紹嗎? – StuartLC 2012-07-09 16:56:39

回答

0

好吧好吧我解決我的問題,但我的問題變成了什麼都沒有做,我描述錯誤。由於IE緩存了ajax調用,我遇到了錯誤,並且通過添加jQuery.ajaxSetup({cache:false})能夠解決此問題。

0

這並沒有爲我工作。我發現的修補程序是將X-UA兼容值添加到每個控制器的Interceptor之前,並且似乎每次都能使其工作。例如,我在每個控制器中都有

def beforeInterceptor = [action : this.&setBrowserCompat] 

private setBrowserCompat(){ 
response.addHeader("X-UA-Compatible", "IE=edge") 
} 

這似乎總是有效。希望這有幫助