2014-09-20 22:59:36 +00:00
|
|
|
var ie_addons_detect = { };
|
2013-10-15 21:27:23 +00:00
|
|
|
|
2013-11-05 07:04:52 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this ActiveX is available, otherwise false.
|
|
|
|
* Grabbed this directly from browser_autopwn.rb
|
|
|
|
**/
|
2014-09-20 22:59:36 +00:00
|
|
|
ie_addons_detect.hasActiveX = function (axo_name, method) {
|
2013-11-05 07:04:52 +00:00
|
|
|
var axobj = null;
|
|
|
|
if (axo_name.substring(0,1) == String.fromCharCode(123)) {
|
|
|
|
axobj = document.createElement("object");
|
|
|
|
axobj.setAttribute("classid", "clsid:" + axo_name);
|
|
|
|
axobj.setAttribute("id", axo_name);
|
|
|
|
axobj.setAttribute("style", "visibility: hidden");
|
|
|
|
axobj.setAttribute("width", "0px");
|
|
|
|
axobj.setAttribute("height", "0px");
|
|
|
|
document.body.appendChild(axobj);
|
|
|
|
if (typeof(axobj[method]) == 'undefined') {
|
|
|
|
var attributes = 'id="' + axo_name + '"';
|
|
|
|
attributes += ' classid="clsid:' + axo_name + '"';
|
|
|
|
attributes += ' style="visibility: hidden"';
|
|
|
|
attributes += ' width="0px" height="0px"';
|
|
|
|
document.body.innerHTML += "<object " + attributes + "></object>";
|
|
|
|
axobj = document.getElementById(axo_name);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
axobj = new ActiveXObject(axo_name);
|
|
|
|
} catch(e) {
|
|
|
|
// If we can't build it with an object tag and we can't build it
|
|
|
|
// with ActiveXObject, it can't be built.
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (typeof(axobj[method]) != 'undefined') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2013-10-15 21:27:23 +00:00
|
|
|
/**
|
|
|
|
* Returns the version of Microsoft Office. If not found, returns null.
|
|
|
|
**/
|
2014-09-20 22:59:36 +00:00
|
|
|
ie_addons_detect.getMsOfficeVersion = function () {
|
2013-10-15 21:27:23 +00:00
|
|
|
var version;
|
|
|
|
var types = new Array();
|
2013-10-16 04:59:23 +00:00
|
|
|
for (var i=1; i <= 5; i++) {
|
2013-10-15 21:27:23 +00:00
|
|
|
try {
|
|
|
|
types[i-1] = typeof(new ActiveXObject("SharePoint.OpenDocuments." + i.toString()));
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
types[i-1] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (types[0] == 'object' && types[1] == 'object' && types[2] == 'object' &&
|
|
|
|
types[3] == 'object' && types[4] == 'object')
|
|
|
|
{
|
|
|
|
version = "2012";
|
|
|
|
}
|
|
|
|
else if (types[0] == 'object' && types[1] == 'object' && types[2] == 'object' &&
|
|
|
|
types[3] == 'object' && types[4] == null)
|
|
|
|
{
|
|
|
|
version = "2010";
|
|
|
|
}
|
|
|
|
else if (types[0] == 'object' && types[1] == 'object' && types[2] == 'object' &&
|
|
|
|
types[3] == null && types[4] == null)
|
|
|
|
{
|
|
|
|
version = "2007";
|
|
|
|
}
|
|
|
|
else if (types[0] == 'object' && types[1] == 'object' && types[2] == null &&
|
|
|
|
types[3] == null && types[4] == null)
|
|
|
|
{
|
|
|
|
version = "2003";
|
|
|
|
}
|
|
|
|
else if (types[0] == 'object' && types[1] == null && types[2] == null &&
|
|
|
|
types[3] == null && types[4] == null)
|
|
|
|
{
|
|
|
|
// If run for the first time, you must manullay allow the "Microsoft Office XP"
|
|
|
|
// add-on to run. However, this prompt won't show because the ActiveXObject statement
|
|
|
|
// is wrapped in an exception handler.
|
|
|
|
version = "xp";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
version = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return version;
|
|
|
|
}
|