欢迎来到福编程网,本站提供各种互联网专业知识!

新浪中用来显示flash的函数

发布时间:2007-04-02 作者: 来源:转载
新浪中用来显示flash的函数,格式化后大家可以用啊sinaflash.js复制代码代码如下:/***@author[sina]zhangping1@*@versionv1.1.3*Date:2006-9-82006-12-15*/if(typeof(sina)!="object"){varsina={}}sina.$=function(objId){if(!objId){thrownewError("sina.
新浪中用来显示flash的函数,格式化后大家可以用啊
sinaflash.js
复制代码 代码如下:
/**
*@author[sina]zhangping1@
*@versionv1.1.3
*Date:2006-9-82006-12-15
*/
if(typeof(sina)!="object"){varsina={}}
sina.$=function(objId){if(!objId){thrownewError("sina.$(StringobjId)参数必须")}
if(document.getElementById){returneval('document.getElementById("'+objId+'")')}elseif(document.layers){returneval("document.layers['"+objId+"']")}else{returneval('document.all.'+objId)}}
sinaFlash=function(C,v,x,V,c,X,i,O,I,l,o){varz=this;if(!document.createElement||!document.getElementById){return}
z.id=v?v:"";z.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";z.codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+(c?c:"7")+",0,0,0";z.width=x;z.height=V;z.movie=C;z.bgcolor=X?X:null;z.quality=O?O:"high";z.src=z.movie;z.pluginspage="http://www.macromedia.com/go/getflashplayer";z.type="application/x-shockwave-flash";z.useExpressInstall=i?i:null;z.xir=(I)?I:window.location;z.redirectUrl=l?l:null;z.detectKey=o?o:null;z.escapeIs=false;z.objAttrs={};z.params={};z.flashVars=[];z.flashVarsStr="";z.embedAttrs={};z.forSetAttribute("id",z.id);z.objAttrs["classid"]=z.classid;z.forSetAttribute("codebase",z.codebase);z.forSetAttribute("width",z.width);z.forSetAttribute("height",z.height);z.forSetAttribute("movie",z.movie);z.forSetAttribute("quality",z.quality);z.forSetAttribute("pluginspage",z.pluginspage);z.forSetAttribute("type",z.type);z.forSetAttribute("bgcolor",z.bgcolor)}
sinaFlash.prototype={getFlashHtml:function(){varI=this,i='i+='>';for(varlinI.params){i+=''}
if(I.flashVarsStr!=""){i+=''}
i+='i+='>';returni},forSetAttribute:function(I,i){varl=this;I=I.toLowerCase();switch(I){case"classid":break;case"pluginspage":l.embedAttrs["pluginspage"]=i;break;case"src":l.embedAttrs["src"]=i;l.params["movie"]=i;break;case"movie":l.params["movie"]=i;l.embedAttrs["src"]=i;break;case"onafterupdate":case"onbeforeupdate":case"onblur":case"oncellchange":case"onclick":case"ondblClick":case"ondrag":case"ondragend":case"ondragenter":case"ondragleave":case"ondragover":case"ondrop":case"onfinish":case"onfocus":case"onhelp":case"onmousedown":case"onmouseup":case"onmouseover":case"onmousemove":case"onmouseout":case"onkeypress":case"onkeydown":case"onkeyup":case"onload":case"onlosecapture":case"onpropertychange":case"onreadystatechange":case"onrowsdelete":case"onrowenter":case"onrowexit":case"onrowsinserted":case"onstart":case"onscroll":case"onbeforeeditfocus":case"onactivate":case"onbeforedeactivate":case"ondeactivate":case"type":l.embedAttrs["type"]=i;break;case"codebase":l.objAttrs["codebase"]=i;break;case"width":l.objAttrs["width"]=i;l.embedAttrs["width"]=i;break;case"height":l.objAttrs["height"]=i;l.embedAttrs["height"]=i;break;case"align":l.objAttrs["align"]=i;l.embedAttrs["align"]=i;break;case"vspace":l.objAttrs["vspace"]=i;l.embedAttrs["vspace"]=i;break;case"hspace":l.objAttrs["hspace"]=i;l.embedAttrs["hspace"]=i;break;case"class":l.objAttrs["class"]=i;l.embedAttrs["class"]=i;break;case"title":l.objAttrs["title"]=i;break;case"accesskey":l.objAttrs["accesskey"]=i;break;case"name":l.objAttrs["name"]=i;l.embedAttrs["name"]=i;break;case"id":l.objAttrs["id"]=i;l.embedAttrs["name"]=i;break;case"tabindex":l.objAttrs["tabindex"]=i;break;default:l.params[I]=l.embedAttrs[I]=i}},forGetAttribute:function(i){varI=this;i=i.toLowerCase();if(I.objAttrs[i]!=undefined){returnI.objAttrs[i]}elseif(I.embedAttrs[i]!=undefined){returnI.embedAttrs[i]}elseif(I.embedAttrs!=undefined){returnI.embedAttrs[i]}else{returnnull}},setAttribute:function(I,i){this.forSetAttribute(I,i)},getAttribute:function(i){returnthis.forGetAttribute(i)},addVariable:function(I,i){varl=this;if(l.escapeIs){I=escape(I);i=escape(i)}
if(l.flashVarsStr==""){l.flashVarsStr=I+"="+i}else{l.flashVarsStr+="&"+I+"="+i}
l.embedAttrs["FlashVars"]=l.flashVarsStr},getVariable:function(I){varo=this,i=o.flashVarsStr;if(o.escapeIs){I=escape(I)}
varl=newRegExp(I+"=([^&]*)(&?)","i").exec(i);if(o.escapeIs){returnunescape(RegExp.$1)}
returnRegExp.$1},addParam:function(I,i){this.forSetAttribute(I,i)},getParam:function(){returnthis.forGetAttribute(name)},write:function(i){varI=this;if(typeofi=="string"){sina.$(i).innerHTML=I.getFlashHtml()}elseif(typeofi=="object"){i.innerHTML=I.getFlashHtml()}}}/**
*@author[sina]zhangping1@
*@versionv1.1.3
*Date:2006-9-82006-12-15
*/
if(typeof(sina)!="object"){
varsina={
}
}
sina.$=function(objId){
if(!objId){
thrownewError("sina.$(StringobjId)参数必须")
}
if(document.getElementById){
returneval('document.getElementById("'+objId+'")')
}elseif(document.layers){
returneval("document.layers['"+objId+"']")
}else{
returneval('document.all.'+objId)
}
}
sinaFlash=function(C,v,x,V,c,X,i,O,I,l,o){
varz=this;
if(!document.createElement||!document.getElementById){
return
}
z.id=v?v:"";
z.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
z.codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+(c?c:"7")+",0,0,0";
z.width=x;
z.height=V;
z.movie=C;
z.bgcolor=X?X:null;
z.quality=O?O:"high";
z.src=z.movie;
z.pluginspage="http://www.macromedia.com/go/getflashplayer";
z.type="application/x-shockwave-flash";
z.useExpressInstall=i?i:null;
z.xir=(I)?I:window.location;
z.redirectUrl=l?l:null;
z.detectKey=o?o:null;
z.escapeIs=false;
z.objAttrs={
};
z.params={
};
z.flashVars=[];
z.flashVarsStr="";
z.embedAttrs={
};
z.forSetAttribute("id",z.id);
z.objAttrs["classid"]=z.classid;
z.forSetAttribute("codebase",z.codebase);
z.forSetAttribute("width",z.width);
z.forSetAttribute("height",z.height);
z.forSetAttribute("movie",z.movie);
z.forSetAttribute("quality",z.quality);
z.forSetAttribute("pluginspage",z.pluginspage);
z.forSetAttribute("type",z.type);
z.forSetAttribute("bgcolor",z.bgcolor)
}
sinaFlash.prototype={
getFlashHtml:function(){
varI=this,i='for(varlinI.objAttrs){
i+=l+'="'+I.objAttrs[l]+'"'
}
i+='>';
for(varlinI.params){
i+=''
}
if(I.flashVarsStr!=""){
i+=''
}
i+='for(varlinI.embedAttrs){
i+=l+'="'+I.embedAttrs[l]+'"'
}
i+='>';
returni
},forSetAttribute:function(I,i){
varl=this;
I=I.toLowerCase();
switch(I){
case"classid":break;
case"pluginspage":l.embedAttrs["pluginspage"]=i;
break;
case"src":l.embedAttrs["src"]=i;
l.params["movie"]=i;
break;
case"movie":l.params["movie"]=i;
l.embedAttrs["src"]=i;
break;
case"onafterupdate":case"onbeforeupdate":case"onblur":case"oncellchange":case"onclick":case"ondblClick":case"ondrag":case"ondragend":case"ondragenter":case"ondragleave":case"ondragover":case"ondrop":case"onfinish":case"onfocus":case"onhelp":case"onmousedown":case"onmouseup":case"onmouseover":case"onmousemove":case"onmouseout":case"onkeypress":case"onkeydown":case"onkeyup":case"onload":case"onlosecapture":case"onpropertychange":case"onreadystatechange":case"onrowsdelete":case"onrowenter":case"onrowexit":case"onrowsinserted":case"onstart":case"onscroll":case"onbeforeeditfocus":case"onactivate":case"onbeforedeactivate":case"ondeactivate":case"type":l.embedAttrs["type"]=i;
break;
case"codebase":l.objAttrs["codebase"]=i;
break;
case"width":l.objAttrs["width"]=i;
l.embedAttrs["width"]=i;
break;
case"height":l.objAttrs["height"]=i;
l.embedAttrs["height"]=i;
break;
case"align":l.objAttrs["align"]=i;
l.embedAttrs["align"]=i;
break;
case"vspace":l.objAttrs["vspace"]=i;
l.embedAttrs["vspace"]=i;
break;
case"hspace":l.objAttrs["hspace"]=i;
l.embedAttrs["hspace"]=i;
break;
case"class":l.objAttrs["class"]=i;
l.embedAttrs["class"]=i;
break;
case"title":l.objAttrs["title"]=i;
break;
case"accesskey":l.objAttrs["accesskey"]=i;
break;
case"name":l.objAttrs["name"]=i;
l.embedAttrs["name"]=i;
break;
case"id":l.objAttrs["id"]=i;
l.embedAttrs["name"]=i;
break;
case"tabindex":l.objAttrs["tabindex"]=i;
break;
default:l.params[I]=l.embedAttrs[I]=i
}
},forGetAttribute:function(i){
varI=this;
i=i.toLowerCase();
if(I.objAttrs[i]!=undefined){
returnI.objAttrs[i]
}elseif(I.embedAttrs[i]!=undefined){
returnI.embedAttrs[i]
}elseif(I.embedAttrs!=undefined){
returnI.embedAttrs[i]
}else{
returnnull
}
},setAttribute:function(I,i){
this.forSetAttribute(I,i)
},getAttribute:function(i){
returnthis.forGetAttribute(i)
},addVariable:function(I,i){
varl=this;
if(l.escapeIs){
I=escape(I);
i=escape(i)
}
if(l.flashVarsStr==""){
l.flashVarsStr=I+"="+i
}else{
l.flashVarsStr+="&"+I+"="+i
}
l.embedAttrs["FlashVars"]=l.flashVarsStr
},getVariable:function(I){
varo=this,i=o.flashVarsStr;
if(o.escapeIs){
I=escape(I)
}
varl=newRegExp(I+"=([^&]*)(&?)","i").exec(i);
if(o.escapeIs){
returnunescape(RegExp.$1)
}
returnRegExp.$1
},addParam:function(I,i){
this.forSetAttribute(I,i)
},getParam:function(){
returnthis.forGetAttribute(name)
},write:function(i){
varI=this;
if(typeofi=="string"){
sina.$(i).innerHTML=I.getFlashHtml()
}elseif(typeofi=="object"){
i.innerHTML=I.getFlashHtml()
}
}
}

调用方法:
复制代码 代码如下:

不支持Flash


varobjFlash=newsinaFlash("http://ad4.sina.com.cn/200703/28/86132_58590.swf","","585","90","7","",false,"high");
objFlash.addParam("wmode","opaque");
objFlash.addVariable("adlink",escape("http://bf.sina.com.cn/newbf/zt/07qycs.html"));
objFlash.write("flashcontent_01639EBFB760");




不支持Flash


varobjFlash=newsinaFlash("http://ad4.sina.com.cn/200704/02/86722_sina402news58550.swf","","585","50","7","",false,"high");
objFlash.addParam("wmode","opaque");
objFlash.write("flashcontent_97C36D34A728");




相关推荐