1: function getFlashVersion() {
2: var flashVer = NaN;
3: var ua = navigator.userAgent;
4:
5: if (window.ActiveXObject) {
6: var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
7:
8: if (swf) {
9: flashVer = Number(swf.GetVariable('$version').split(' ')[1].replace(/\,/g, '.').replace(/^(\d+\.\d+).*$/, "$1"));
10: }
11: } else {
12: if (navigator.plugins && navigator.plugins.length > 0) {
13: var swf = navigator.plugins['Shockwave Flash'];
14:
15: if (swf) {
16: var arr = swf.description.split(' ');
17: for (var i = 0, len = arr.length; i < len; i++) {
18: var ver = Number(arr[i]);
19:
20: if (!isNaN(ver)) {
21: flashVer = ver;
22: break;
23: }
24: }
25: }
26: }
27: }
28:
29: return flashVer;
30: }
31:
32:
33: var flashVer = getFlashVersion();
34:
35: if (!isNaN(flashVer)) {
36:
37: document.write('当前flash player 的版本:' + flashVer);
38:
39: } else {
40: document.write('您尚未安装flash播放器');
41: }