如何检测浏览器并根据浏览器显示视频

How to detect browser and show video according to browser

本文关键字:浏览器 显示 视频 何检测 检测      更新时间:2023-09-26

我想根据浏览器显示视频,如果某个页面在chrome中打开,那么chrome.mp4应该播放等等。

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="jquery-1.11.2.min.js" type="application/javascript" language="javascript"></script>
<script>
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
    // Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
    // At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera;              // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode;   // At least IE6
if(isFirefox==true)
{
    $("#my").html("<embed src='mozilla.mp4'></embed>");
}
</script>
</head>
<body>
<div id="my"></div>
</body>
</html>

这是我当前的代码。

Modernizr.js来检测什么浏览器可以使用什么类型的属性等等。