Web|web Standard | insert
HTML Code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<meta http-equiv= "Content-type" content= "text/html; Charset=iso-8859-1 "/>
<title>flashobject embed by Geoff Stearns (Basic) @ deconcept</title>
<!--Flashobject Embed by Geoff Stearns geoff@deconcept.com http://blog.deconcept.com/flashobject/-->
<script type= "Text/javascript" src= "Flashobject.js" ></script>
<body>
<script type= "Text/javascript" >
<! [cdata[
var fo = new Flashobject ("fo_tester.swf", "Fotester", "," "," "6", "#FF6600");
Fo.addvariable ("Flashvartext", "this are passed in via Flashvars for example only"); This are optional, but this example uses the variable and displays this text inside the Flash movie
Fo.write ("Flashcontent");
]]>
</script>
</body>
Flashobject.js Code:
This.installedver = Com.deconcept.FlashObjectUtil.getPlayerVersion (This.getattribute (' Version '), Useexpressinstall);
if (c) this.addparam (' bgcolor ', c);
var q = quality? Quality: ' High ';
This.addparam (' quality ', q);
var Xir = (xiredirecturl)? XiRedirectUrl:window.location;
This.setattribute (' Xiredirecturl ', Xir);
This.setattribute (' RedirectURL ', ');
if (redirecturl) this.setattribute (' RedirectURL ', redirecturl);
}
Com.deconcept.FlashObject.prototype = {
Setattribute:function (name, value) {
This.attributes[name] = value;
},
Getattribute:function (name) {
return This.attributes[name];
},
Addparam:function (name, value) {
This.params[name] = value;
},
Getparams:function () {
return this.params;
},
Addvariable:function (name, value) {
This.variables[name] = value;
},
Getvariable:function (name) {
return This.variables[name];
},
Getvariables:function () {
return this.variables;
},
Createparamtag:function (n, v) {
var p = document.createelement (' param ');
P.setattribute (' name ', n);
P.setattribute (' value ', V);
return p;
},
Getvariablepairs:function () {
var variablepairs = new Array ();
var key;
var variables = this.getvariables ();
For (key in variables) {
Variablepairs.push (key + "=" + Variables[key]);
}
return variablepairs;
},
Getflashhtml:function () {
var flashnode = "";
if (navigator.plugins && navigator.mimetypes && navigator.mimeTypes.length) {//Netscape Plugin Architecture
if (This.getattribute ("Doexpressinstall")) this.addvariable ("Mmplayertype", "PlugIn");
Flashnode = ' <embed type= ' application/x-shockwave-flash ' src= ' + this.getattribute (' swf ') + ' width= ' + This.getattribute (' width ') + ' "height=" ' + this.getattribute (' height ') + ' ";
Flashnode + = ' id= ' + this.getattribute (' id ') + ' name= ' + this.getattribute (' id ') + ' ";
var params = This.getparams ();
for (var key in params) {Flashnode = = [key] + ' = ' + Params[key] + ' ';}
var pairs = This.getvariablepairs (). Join ("&");
if (Pairs.length > 0) {flashnode + = ' flashvars= ' + pairs + ' "';}
Flashnode + = '/> ';
else {//PC IE
if (This.getattribute ("Doexpressinstall")) this.addvariable ("Mmplayertype", "ActiveX");
Flashnode = ' <object id= ' + this.getattribute (' id ') + ' classid= ' clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 ' width = "' + this.getattribute (' width ') + '" height= "' + this.getattribute (' height ') + ' > ';
Flashnode + = ' <param name= ' movie ' value= ' + this.getattribute (' swf ') + '/> ';
var params = This.getparams ();
for (var key in params) {
Flashnode + = ' <param name= ' + key + ' "value=" ' + params[key] + '/> ';
}
var pairs = This.getvariablepairs (). Join ("&");
if (Pairs.length > 0) Flashnode + = ' <param name= ' flashvars ' value= ' ' + pairs + ' '/> ';
Flashnode = "</object>";
}
return flashnode;
},
Write:function (ElementID) {
if (This.useexpressinstall) {
Check to the if we need to does an express install
var expressinstallreqver = new Com.deconcept.PlayerVersion ([6,0,65]);
if (This.installedVer.versionIsValid (expressinstallreqver) &&!this.installedver.versionisvalid ( This.getattribute (' version ')) {
This.setattribute (' Doexpressinstall ', true);
This.addvariable ("Mmredirecturl", Escape (This.getattribute (' Xiredirecturl '));
Document.title = Document.title.slice (0) + "-Flash Player Installation";
This.addvariable ("Mmdoctitle", document.title);
}
} else {
This.setattribute (' Doexpressinstall ', false);
}
if (This.skipdetect | | this.getattribute (' doexpressinstall ') | | | this.installedVer.versionIsValid (This.getattribute ( ' Version ')) {
var n = (typeof ElementID = = ' string ')? document.getElementById (ElementID): ElementID;
n.innerhtml = this.getflashhtml ();
}else{
if (This.getattribute (' RedirectURL ')!= "") {
Document.location.replace (This.getattribute (' RedirectURL '));
}
}
}
}
* *----DETECTION functions----* *
Com.deconcept.FlashObjectUtil.getPlayerVersion = function (Reqver, xiinstall) {
var playerversion = new Com.deconcept.PlayerVersion (0,0,0);
if (navigator.plugins && navigator.mimeTypes.length) {
var x = navigator.plugins["Shockwave Flash"];
if (x && x.description) {
Playerversion = new Com.deconcept.PlayerVersion (X.description.replace (/) ([a-z]|[ a-z]|\s) +/, ""). Replace (/(\s+r|\s+b[0-9]+)/, "."). Split ("."));
}
}else{
try{
var Axo = new ActiveXObject ("Shockwaveflash.shockwaveflash");
for (var i=3; axo!=null; i++) {
Axo = new ActiveXObject ("Shockwaveflash.shockwaveflash." +i);
Playerversion = new Com.deconcept.PlayerVersion ([i,0,0]);
}
}catch (e) {}
if (reqver && playerversion.major > Reqver.major) return playerversion; Version is OK, skip minor detection
This is only does the Minor Rev lookup if the user ' s major version
Is isn't 6 or we are checking for a specific minor or revision number
http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
if (!reqver | | ((reqver.minor!= 0 | | Reqver.rev!= 0) && playerversion.major = reqver.major) | | Playerversion.major!= 6 | | Xiinstall) {
try{
Playerversion = new Com.deconcept.PlayerVersion (Axo. GetVariable ("$version"). Split ("") [1].split (","));
}catch (e) {}
}
}
return playerversion;
}
Com.deconcept.PlayerVersion = function (arrversion) {
This.major = parseint (arrversion[0]) | | 0;
This.minor = parseint (arrversion[1]) | | 0;
This.rev = parseint (arrversion[2]) | | 0;
}
Com.deconcept.PlayerVersion.prototype.versionIsValid = function (FV) {
if (This.major < fv.major) return false;
if (This.major > Fv.major) return true;
if (This.minor < Fv.minor) return false;
if (This.minor > Fv.minor) return true;
if (This.rev < Fv.rev) return false;
return true;
}
/*----Get value of query string param----/*
Com.deconcept.util = {
Getrequestparameter:function (param) {
var q = Document.location.search | | Document.location.href.hash;
if (q) {
var startIndex = q.indexof (param + "=");
var endindex = (Q.indexof ("&", StartIndex) >-1)? Q.indexof ("&", StartIndex): q.length;
if (Q.length > 1 && startIndex >-1) {
Return q.substring (q.indexof ("=", StartIndex) +1, endindex);
}
}
Return "";
},
Removechildren:function (n) {
while (N.haschildnodes ()) N.removechild (N.firstchild);
}
}
/* Add Array.push if needed (IE5) */
if (Array.prototype.push = = null) {Array.prototype.push = function (item) {This[this.length] = Item; return this.length; }}
/* Add some aliases for ease of use/backwards compatibility * *
var getqueryparamvalue = Com.deconcept.util.getRequestParameter;
var flashobject = Com.deconcept.FlashObject;