2012-05-02 45 views
2

我知道<video>標記在Internet Explorer 8中不起作用,這很好。我想要做的是,如果用戶試圖打開與IE8的鏈接,則顯示一個類似於you're using browser XX and it's not supported的錯誤。Internet Explorer 8中的HTML5視頻

我嘗試這樣做:

<video id="ivideo" src="skins/Sandbox_Light/styleVideos/anima.mp4" controls onended="ivideo();" style="width:952px; height=435px" autoplay="autoplay"> 
    Not supported by your browser 
</video> 

但是,相反,我看到一個黑色div與X在中間,好像這個問題是從插件丟失。我試圖打開this page,它在IE9中正常工作。

回答

1

使用這段代碼功能檢測到它:

function supports_video() { 
    return !!document.createElement('video').canPlayType; 
} 

禮貌潛水進入HTML5:http://diveintohtml5.info/detect.html

+0

我試圖把該片斷的頭和它的調用函數的onload;什麼都沒有發生,所以我在地址欄中調用了funcion(javascript:supports_video();),它出現在屏幕上「TRUE」;我猜這是假設這是可玩的,但它不是... – Souza

+0

有趣的是,您可能必須通過調用canPlayType()來擴展功能檢測,如前面提到的html5文章中所述。 –

0

查看下面鏈接中的IE6阻塞程序腳本。加載HTML 5的

<!--[if <= IE 8]> 
    <script type="text/javascript" src="jquery.ie6blocker.js"></script> 
<![endif]--> 

    <video id="ivideo" src="skins/Sandbox_Light/styleVideos/anima.mp4" controls onended="ivideo();" style="width:952px; height=435px" autoplay="autoplay"> 

然後通過iframe加載視頻

將此放在一個單獨的文件。我會建議編輯腳本來證明你在做什麼,如果需要的話..也改變圖像的大小。另外,把一個鏈接升級瀏覽器。

http://css-tricks.com/ie-6-blocker-script/