0
將文檔模式設置爲默認值以外的值不會在請求中發送相應的User-Agent
標頭(如在IE devtools的網絡選項卡中所見)。但是,在控制檯中執行navigator.userAgent
確實反映了適當的字符串(與文檔模式/用戶代理設置關聯)。IE開發工具文檔模式用戶代理
這是IE開發工具中的一個bug嗎?如果不是,那麼讓IE將相應的User-Agent
標頭髮送到遠程服務器的正確方法是什麼?
將文檔模式設置爲默認值以外的值不會在請求中發送相應的User-Agent
標頭(如在IE devtools的網絡選項卡中所見)。但是,在控制檯中執行navigator.userAgent
確實反映了適當的字符串(與文檔模式/用戶代理設置關聯)。IE開發工具文檔模式用戶代理
這是IE開發工具中的一個bug嗎?如果不是,那麼讓IE將相應的User-Agent
標頭髮送到遠程服務器的正確方法是什麼?
在JavaScript中,document.documentMode
映射到F12開發人員工具。用戶代理不受影響:
務必:
使用以下幾種檢測方法更可靠地檢測誤差的來源,並確保您的網頁在不同瀏覽器兼容:
Feature detection: Test whether a browser supports a feature before you use it. Feature detection enables cross-browser code to "just work" without requiring you to know the capabilities of every browser ahead of time. For example, the jQuery framework relies almost entirely on feature detection. For more info about how you can use jQuery's feature detection in your own site, see the jQuery.support documentation.
Behavior detection: Test for known issues before you apply a workaround. jQuery also uses behavior detection by running tests for known issues to determine if certain workarounds are needed.
不要:
Detect specific browsers: Don't use the identity of a browser (for example, navigator.userAgent) to change a page's behavior. If you change code based on a specific browser, the page cannot easily adapt to changes and it might break when a new browser is released. In other situations, pages use a legacy workaround even when that workaround is no longer needed.
Assume unrelated features: Don't perform feature detection for one feature and then use a different feature. Sites that have this problem perform feature detection for one feature and then use other features without testing whether they are supported.
個
參考
我期待它的工作相應:) – culturalanomoly
第一個錯誤,這是IE瀏覽器,它從未相應的工作原理:d 但在所有的嚴重性,如果你想要測試不同版本的IE 使用一個名爲IETester的程序 – MarshallOfSound
您是否只設置了「文檔模式」?或者您是否設置了「文檔模式」和「用戶代理字符串」值? 爲了更改發送到服務器的用戶代理報頭請求,您必須更改「用戶代理字符串」值 –