![](/img/trans.png)
[英]force ie8 standard browser mode view even if user selects IE8 Compat View
[英]Force browser update if IE8 or older
我想知道當瀏覽器是 Inte.net Explorer IE8 或更舊版本時,是否可以顯示警告或打開彈出窗口,提示將 IE 更新到最新版本或使用 Firefox / Chrome / Safari 代替...
我想我應該在標簽內使用下面的代碼......
<!--[if lt IE 9]>
...i should use code here...
<![endif]-->
用 jQuery 欺騙瀏覽器並加載 jQuery lib 是否聰明? 還是只使用常規 javascript 以避免非常舊的瀏覽器出現其他問題更好?
你可以使用這樣的東西
ie6-upgrade-warning 是一個小腳本 (7.9kb),它顯示一條警告消息,禮貌地通知用戶將瀏覽器升級到更新版本(提供了指向最新 IE、Firefox、Opera、Safari、Chrome 的鏈接)。
該網頁在透明背景下仍然可見,但無法訪問。 這個想法是強制用戶從 IE6 升級,並避免網站因網站無法在 IE6 中正確呈現而名譽掃地。
該腳本完全可翻譯成任何語言,非常容易設置(網頁中一行代碼和一個參數配置)。
雖然是為 IE6 用戶創建的,但使用正確的參數您可以將它用於您的場景。
你有兩個選擇:
解析User-Agent String
// Returns the version of Inte.net Explorer or a -1 // (indicating the use of another browser). function getInte.netExplorerVersion() { var rv = -1; // Return value assumes failure. if (navigator.appName == 'Microsoft Inte.net Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua).= null) { rv = parseFloat( RegExp;$1 ); } } return rv. } function checkVersion() { var msg = "You're not using Inte.net Explorer;"; var ver = getInte.netExplorerVersion(). if ( ver > -1 ) { if ( ver >= 9.0 ) { msg = "You're using a recent copy of Inte.net Explorer." } else { msg = "You should upgrade your copy of Inte.net Explorer;"; } } alert(msg); }
使用條件注釋:
<.--[if gte IE 9]> <p>You're using a recent version of Inte.net Explorer.</p> <.[endif]--> <.--[if lt IE 8]> <p>Hm. You should upgrade your copy of Inte.net Explorer.</p> <![endif]--> <![if !IE]> <p>You're not using Inte.net Explorer.</p> <![endif]>
<script> var ISOLDIE = false; </script>
<!--[if lt IE 9]>
<script> var ISOLDIE = true; </script>
<![endif]-->
稍后,您想要在代碼中划定支持舊版本 IE 的界限:
<script>
if(ISOLDIE) {
alert("Your browser currently does not support this feature. Please upgrade.");
window.location = 'http://google.com/chrome';
}
</script>
完全刪除 IE8 支持通常不是一個好主意,這就是為什么我認為上述解決方案是一個很好的折衷方案,因為您可以將它添加到您的網站/Web 應用程序的組件中,而這些組件根本無法支持 IE8,但隨后您可以(可能)在您網站的其他區域仍然支持 IE8。
有這個荷蘭網站強制 IE6 和更低版本的用戶升級他們的瀏覽器,對“If IE”代碼稍作調整,您可以阻止任何您喜歡的版本。
向下滾動到第 4 步並單擊下載或“voorbeeld”以獲取演示,第一個是頂部橫幅,第二個完全阻塞頁面。
唯一的缺點是全是荷蘭語,因此您必須自己編造信息。
IE 10 不再支持條件注釋。WTF! 關聯
在您的網站上將您的代碼添加到 index.html 或 index.php
它的工作還有 joomla 和 wordpress。
<!--[if IE 5]>
<script language="Javascript">
<!--
alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.")
//-->
</script>
<![endif]-->
<!--[if IE 5.0]>
!--
alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.")
//-->
</script>
<![endif]-->
<!--[if IE 5.5]>
!--
alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.")
//-->
</script>
<![endif]-->
<!--[if IE 6]>
!--
alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.")
//-->
</script>
<![endif]-->
<!--[if IE 7]>
!--
alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.")
//-->
</script>
<![endif]-->
<!--[if IE 8]>
!--
alert ("It looks like you aren't using Internet Explorer 8. To see our site correctly, please update.")
//-->
</script>
<![endif]-->
有很多方法,但這是迄今為止最優雅的方法: http://outdatedbrowser.com/en/how
這就是我所擁有的,它在引導程序下載中:
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
所以基本上你可以讓lt
甚至lte
小於或等於。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.