class FlashPlayerController { // 構造函數, 大部分的邏輯代碼最好寫在$onInit中, constructor 初始化一些變量 constructor($timeout) { } // 初始化完畢加載 $onInit($timeout) { this.checkFlashPlayer = function () { var hasFlashPlayer = 0; //判斷是否安裝了Flash Player var flashPlayerVersion = 0; //Flash Player版本 if (document.all) { var shockWaveFlash = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); if (shockWaveFlash) { hasFlashPlayer = 1; flashPlayerVersion = parseInt(shockWaveFlash.GetVariable("$version").split(" ")[1].split(",")[0]); } } else if (navigator.plugins && navigator.plugins.length > 0) { var shockWaveFlash = navigator.plugins["Shockwave Flash"]; if (shockWaveFlash) { hasFlashPlayer = 1; var descriptionInfo = shockWaveFlash.description.split(" "); for (var i = 0; i < descriptionInfo.length; ++i) { if (isNaN(parseInt(descriptionInfo[i]))) { continue; } flashPlayerVersion = parseInt(descriptionInfo[i]); } } } return {hasFlashPlayer: hasFlashPlayer, flashPlayerVersion: flashPlayerVersion}; }; if (this.checkFlashPlayer().hasFlashPlayer) { if (this.checkFlashPlayer().flashPlayerVersion <= 10) { if (confirm("您的Flash Player版本太低,當即升級Flash Player版本?")) { window.location.href = "http://get.adobe.com/cn/flashplayer/"; } } else { // alert("您安裝了Flash Player,當前Flash Player版本號爲:" + this.checkFlashPlayer().flashPlayerVersion + "。"); } } else { if (confirm("您沒有安裝Flash Player,當即安裝?")) { window.location.href = "http://get.adobe.com/cn/flashplayer/"; } } } }