同事報案,某網頁使用http: //servername/ap/page.aspx連線時測試正常,換個URL,使用http: //servername.domain.com/ap/page.aspx連至同一網頁卻會發生document.getElementById(...)找不到物件的錯誤。追蹤後,發現是IE8標準模式下ID/NAME屬性會區分大小寫老問題 -- 用document.getElementById("txt_input")去取得<input id="txt_Input" />,在IE8標準模式下會出錯!!

但有趣的問題來了,莫非URL也會影響IE8使用模準模式或相容模式?

爬文後,找到了解答

A large number of line-of-business websites are Internet Explorer 7 capable today. In order to preserve compatibility, Internet Explorer 8 ships with smart defaults based on zone evaluation. In the default state, all sites on the public internet display in Internet Explorer 8 Standards mode (Compatibility View off) and all intranet websites display in Internet Explorer 7 Standards mode (Compatibility View on).

原來,IE8還真的會依站台所屬的"區域"[內部網路(Local Intranet)、網際網路、信任的站台...]自動調整模式,基於企業內部網站系統很多還只支援IE7,為了保持相容性,屬於網際網路區域的網站會預設使用IE8標準模式;內部網路區域所指向的多半是企業內部網站,故預設使用IE7標準模式。這個特性解釋了今天遇到的狀況。

射完茶包,又長了見識!


Comments

# by ChaN

黑大,我在期待您的 jQuery 1.5 文啊 XDDDDD

Post a comment