flashobject.js
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:6k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

JavaScript

  1. /**
  2.  * FlashObject v1.3d: Flash detection and embed - http://blog.deconcept.com/flashobject/
  3.  *
  4.  * FlashObject is (c) 2006 Geoff Stearns and is released under the MIT License:
  5.  * http://www.opensource.org/licenses/mit-license.php
  6.  *
  7.  */
  8. if(typeof com=="undefined"){var com=new Object();}
  9. if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}
  10. if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}
  11. if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}
  12. com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
  13. if(!document.createElement||!document.getElementById){return;}
  14. this.DETECT_KEY=_b?_b:"detectflash";
  15. this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);
  16. this.params=new Object();
  17. this.variables=new Object();
  18. this.attributes=new Array();
  19. this.useExpressInstall=_7;
  20. if(_1){this.setAttribute("swf",_1);}
  21. if(id){this.setAttribute("id",id);}
  22. if(w){this.setAttribute("width",w);}
  23. if(h){this.setAttribute("height",h);}
  24. if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}
  25. this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
  26. if(c){this.addParam("bgcolor",c);}
  27. var q=_8?_8:"high";
  28. this.addParam("quality",q);
  29. var _d=(_9)?_9:window.location;
  30. this.setAttribute("xiRedirectUrl",_d);
  31. this.setAttribute("redirectUrl","");
  32. if(_a){this.setAttribute("redirectUrl",_a);}
  33. };
  34. com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){
  35. this.attributes[_e]=_f;
  36. },getAttribute:function(_10){
  37. return this.attributes[_10];
  38. },addParam:function(_11,_12){
  39. this.params[_11]=_12;
  40. },getParams:function(){
  41. return this.params;
  42. },addVariable:function(_13,_14){
  43. this.variables[_13]=_14;
  44. },getVariable:function(_15){
  45. return this.variables[_15];
  46. },getVariables:function(){
  47. return this.variables;
  48. },createParamTag:function(n,v){
  49. var p=document.createElement("param");
  50. p.setAttribute("name",n);
  51. p.setAttribute("value",v);
  52. return p;
  53. },getVariablePairs:function(){
  54. var _19=new Array();
  55. var key;
  56. var _1b=this.getVariables();
  57. for(key in _1b){_19.push(key+"="+_1b[key]);}
  58. return _19;
  59. },getFlashHTML:function(){
  60. var _1c="";
  61. if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
  62. if(this.getAttribute("doExpressInstall")){
  63. this.addVariable("MMplayerType","PlugIn");
  64. }
  65. _1c="<embed type="application/x-shockwave-flash" src=""+this.getAttribute("swf")+"" width=""+this.getAttribute("width")+"" height=""+this.getAttribute("height")+""";
  66. _1c+=" id=""+this.getAttribute("id")+"" name=""+this.getAttribute("id")+"" ";
  67. var _1d=this.getParams();
  68. for(var key in _1d){_1c+=[key]+"=""+_1d[key]+"" ";}
  69. var _1f=this.getVariablePairs().join("&");
  70. if(_1f.length>0){_1c+="flashvars=""+_1f+""";}
  71. _1c+="/>";
  72. }else{
  73. if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
  74. _1c="<object id=""+this.getAttribute("id")+"" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width=""+this.getAttribute("width")+"" height=""+this.getAttribute("height")+"">";
  75. _1c+="<param name="movie" value=""+this.getAttribute("swf")+"" />";
  76. var _20=this.getParams();
  77. for(var key in _20){_1c+="<param name=""+key+"" value=""+_20[key]+"" />";}
  78. var _22=this.getVariablePairs().join("&");
  79. if(_22.length>0){_1c+="<param name="flashvars" value=""+_22+"" />";
  80. }_1c+="</object>";}
  81. return _1c;
  82. },write:function(_23){
  83. if(this.useExpressInstall){
  84. var _24=new com.deconcept.PlayerVersion([6,0,65]);
  85. if(this.installedVer.versionIsValid(_24)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
  86. this.setAttribute("doExpressInstall",true);
  87. this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
  88. document.title=document.title.slice(0,47)+" - Flash Player Installation";
  89. this.addVariable("MMdoctitle",document.title);}
  90. }else{this.setAttribute("doExpressInstall",false);}
  91. if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
  92. var n=(typeof _23=="string")?document.getElementById(_23):_23;
  93. n.innerHTML=this.getFlashHTML();
  94. }else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}}};
  95. com.deconcept.FlashObjectUtil.getPlayerVersion=function(_26,_27){
  96. var _28=new com.deconcept.PlayerVersion(0,0,0);
  97. if(navigator.plugins&&navigator.mimeTypes.length){
  98. var x=navigator.plugins["Shockwave Flash"];
  99. if(x&&x.description){_28=new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|s)+/,"").replace(/(s+r|s+b[0-9]+)/,".").split("."));}
  100. }else{
  101. try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  102. for(var i=3;axo!=null;i++){
  103. axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
  104. _28=new com.deconcept.PlayerVersion([i,0,0]);}}
  105. catch(e){}
  106. if(_26&&_28.major>_26.major){return _28;}
  107. if(!_26||((_26.minor!=0||_26.rev!=0)&&_28.major==_26.major)||_28.major!=6||_27){
  108. try{
  109. _28=new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
  110. }catch(e){}}}
  111. return _28;
  112. };
  113. com.deconcept.PlayerVersion=function(_2c){
  114. this.major=parseInt(_2c[0])||0;
  115. this.minor=parseInt(_2c[1])||0;
  116. this.rev=parseInt(_2c[2])||0;
  117. };
  118. com.deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
  119. if(this.major<fv.major){return false;}
  120. if(this.major>fv.major){return true;}
  121. if(this.minor<fv.minor){return false;}
  122. if(this.minor>fv.minor){return true;}
  123. if(this.rev<fv.rev){return false;}
  124. return true;
  125. };
  126. com.deconcept.util={getRequestParameter:function(_2e){
  127. var q=document.location.search||document.location.hash;
  128. if(q){var _30=q.indexOf(_2e+"=");
  129. var _31=(q.indexOf("&",_30)>-1)?q.indexOf("&",_30):q.length;
  130. if(q.length>1&&_30>-1){
  131. return q.substring(q.indexOf("=",_30)+1,_31);}}return "";
  132. },removeChildren:function(n){
  133. while(n.hasChildNodes()){
  134. n.removeChild(n.firstChild);}}};
  135. if(Array.prototype.push==null){
  136. Array.prototype.push=function(_33){
  137. this[this.length]=_33;
  138. return this.length;};}
  139. var getQueryParamValue=com.deconcept.util.getRequestParameter;
  140. var FlashObject=com.deconcept.FlashObject;