您的位置:首页 > 编程语言

解决IE需要激活 ActiveX 控件和生成控件调用代码

2006-12-25 22:20 579 查看
//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>
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐