搜索:
首页 >> JavaScript >> Js高级编程 >> AXObject解决IE需要激活 ActiveX 控件方法

AXObject解决IE需要激活 ActiveX 控件方法

2007-11-8 作者:冷月宫主 来源:冷月学堂 投递文章

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();
    }
}

 


AXObject调用实例;
<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>

Tags:AXObjec  激活  ie  ActiveX 
相关文章
手机版 Js高级编程 Asp之家 Aspxhome.com
闽ICP备06017341号