AXObject可用來解決IE需要啟用 ActiveX 控件和產生控件引用程式碼來源:
http://www.klstudio.com/post/96.html
AXObject可用來解決IE需要啟用 ActiveX 控件和產生控件引用程式碼
AXObject類是參考SWFObject類來寫得,或者說是把原來僅限於Flash控件再擴大範圍,可適用於其他像MediaPlayer,RealPlayer等ActiveX控件!本身程式碼並不複雜,只是為了方便大家也方便自己,也就貼出來了,希望對你有點輔助!
以下內容為程式語法:
//AXObject.js程式碼
function AXObject(id,classid,tagName){
this.tagName = (typeof tagName == 'string')?tagName:"object";
this.params = new Object();
this.variables = new Object();
this.setVariable("id",id);
this.setVariable("name",id);
this.setVariable("classid",classid);
}
AXObject.prototype.setParam = function(key,value){
this.params[key] = value;
}
AXObject.prototype.getParam = function(key){
return this.params[key];
}
AXObject.prototype.getParams = function(){
return this.params;
}
AXObject.prototype.setVariable = function(key,value){
this.variables[key] = value;
}
AXObject.prototype.getVariable = function(key){
return this.variables[key];
}
AXObject.prototype.getVariables = function(key){
return this.variables;
}
AXObject.prototype.getHtml = function(){
var con = '<'+this.tagName+' ';
var variables = this.getVariables();
for(var key in variables){
con += key + '="' + variables[key] + '" ';
}
con += ' >';
var params = this.getParams();
for(var key in params){
con += '<param name="'+ key +'" value="'+ params[key] +'" />';
}
con += '</'+this.tagName+'>';
return con;
}
AXObject.prototype.write = function(elementId){
if(typeof elementId == 'undefined'){
document .write(this.getHtml());
}else{
var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
n.innerHTML = this.getHtml();
}
}
以下內容為程式語法:
//引用實例;
<script language="javascript">
var axo = new AXObject("mediaPlayerObject","clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6");
axo.setVariable("width","400");
axo.setVariable("height","300");
axo.setParam("URL","http://bbmedia.qq.com/media/game/2006/06/20060626contra.wmv");
axo.setParam("rate","1");
axo.setParam("balance","0");
axo.setParam("currentPosition","0");
axo.setParam("playCount","1");
axo.setParam("autoStart","0");
axo.setParam("currentMarker","0");
axo.setParam("invokeURLs","-1");
axo.setParam("volume","0");
axo.setParam("mute","0");
axo.setParam("uiMode","full");
axo.setParam("stretchToFit","-1");
axo.setParam("windowlessVideo","0");
axo.setParam("enabled","-1");
axo.setParam("enableContextMenu","0");
axo.setParam("fullScreen","0");
axo.setParam("enableErrorDialogs","0");
axo.write();
</script>