JS 브라우저가 acrobat reader를 지원하는지 판단

2524 단어 reader
var adobeReaderInfo = {
	installed: false,
	version: "0.0",
	goRedirect: false,
	getAdobeReader: function() {
		//  Firefox 
		if (navigator.plugins && navigator.plugins.length) {
			for (var x = 0; x < navigator.plugins.length; x++) {
				if (navigator.plugins[x].description.indexOf("Adobe Acrobat") != -1) {
					adobeReaderInfo.version = parseFloat(navigator.plugins[x].description
						.split("Version ")[1]);
					if (adobeReaderInfo.version.toString().length == 1)
						adobeReaderInfo.version += ".0";
					adobeReaderInfo.installed = true;
					break;
				} else if (navigator.plugins[x].description
					.indexOf("Adobe PDF Plug-In") != -1) {
					adobeReaderInfo.installed = true;
					adobeReaderInfo.version = "8+";
					break;
				}
			}
			//  IE 
		} else if (window.ActiveXObject) {
			for (var _x = 2; _x < 10; _x++) {
				try {
					oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + _x + "');");
					if (oAcro) {
						adobeReaderInfo.installed = true;
						adobeReaderInfo.version = _x + ".0";
					}
				} catch (e) {}
			}
			try {
				oAcro4 = new ActiveXObject("PDF.PdfCtrl.1");
				if (oAcro4) {
					adobeReaderInfo.installed = true;
					adobeReaderInfo.version = '4.0';
				}
			} catch (e) {}

			try {
				oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
				if (oAcro7) {
					adobeReaderInfo.installed = true;
					adobeReaderInfo.version = '7.0';
				}
			} catch (e) {}
		}
	},
	judgeAdobe: function() {
		if (adobeReaderInfo.installed) {
			if (parseInt(adobeReaderInfo.version, 10) < 7) {
				if (confirm("Adobe Reader  , ?")) {
					adobeReaderInfo.goRedirect = false;
					window.open("http://get.adobe.com/cn/reader/", "", "");
					return false;
				} else {
					adobeReaderInfo.goRedirect = true;
				}
			} else {
				adobeReaderInfo.goRedirect = true;
			}
		} else {
			if (confirm(" Adobe Reader")) {
				window.open("http://get.adobe.com/cn/reader/", "", "");
				return false;
			}
		}
	}
};

좋은 웹페이지 즐겨찾기