1.在页面中引入下面这段代码,页面上所有Flash在浏览时都不会在有虚线框:
1

/**//*2
xpengfee search from www at 2007-08-243
put it in your page,then the flash of the page will be no deshed4
*/5
var ie = (document.defaultCharset && document.getElementById && !window.home);6
var opera9 = false;7
if (ie)8


{9
//Check for ie 5.5 and exclude it from the script10
var ver=navigator.appVersion.split("MSIE")11
ver=parseFloat(ver[1])12
ie = (ver >=6)13
}14
else if (navigator.userAgent.indexOf("Opera")!=-1) 15


{16
//Check for Opera9 and include it in the ObjectSwap17
var versionindex=navigator.userAgent.indexOf("Opera")+618
if (parseInt(navigator.userAgent.charAt(versionindex))>=9)19
opera9 = true;20
}21
//Perform ObjectSwap if the browser is IE or Opera (if not just check flashVersion)22
var oswap = (ie || opera9)23

24
//Hide the object to prevent it from loading twice25
if (oswap)26


{27
document.write ("<style id='hideObject'> object{display:none;} </style>");28
}29

30

/**//*Replace all flash objects on the page with the same flash object, 31
by rewriting the outerHTML values32
This bypasses the new IE ActiveX object activation issue*/33
objectSwap = function()34


{35
if (!document.getElementsByTagName)36

{37
return;38
}39
//An array of ids for flash detection40
var stripQueue = [];41
//Get a list of all ActiveX objects42
var objects = document.getElementsByTagName('object');43
for (var i=0; i<objects.length; i++)44

{ 45
var o = objects[i]; 46
var h = o.outerHTML;47
//The outer html omits the param tags, so we must retrieve and insert these separately48
var params = "";49
var hasFlash = true;50
for (var j = 0; j<o.childNodes.length; j++) 51

{52
var p = o.childNodes[j];53
if (p.tagName == "PARAM")54

{55
//Check for version first - applies to all browsers56
//For this to work, a new param needs to be included in the object with the name "flashVersion" eg:57
//<param name="flashVersion" value="7" />58
if (p.name == "flashVersion")59

{60
hasFlash = detectFlash(p.value);61
if (!hasFlash)62

{63
//Add the objects id to the list (create a new id if there's isn't one already)64
o.id = (o.id == "") ? ("stripFlash"+i) : o.id;65
stripQueue.push(o.id);66
break;67
}68
} 69
params += p.outerHTML; 70
}71
} 72
if (!hasFlash)73

{74
continue;75
} 76
//Only target internet explorer77
if (!oswap)78

{79
continue;80
} 81
//Avoid specified objects, marked with a "noswap" classname82
if (o.className.toLowerCase().indexOf ("noswap") != -1)83

{84
continue;85
} 86
//Get the tag and attributes part of the outer html of the object87
var tag = h.split(">")[0] + ">"; 88
//Add up the various bits that comprise the object:89
//The tag with the attributes, the params and it's inner html90
var newObject = tag + params + o.innerHTML + " </OBJECT>"; 91
//And rewrite the outer html of the tag 92
o.outerHTML = newObject;93
}94
//Strip flash objects95
if (stripQueue.length) 96

{97
stripFlash(stripQueue)98
}99
//Make the objects visible again100
if (oswap)101

{102
document.getElementById("hideObject").disabled = true;103
}104
}105

106
detectFlash = function(version)107


{108
if(navigator.plugins && navigator.plugins.length)109

{110
//Non-IE flash detection.111
var plugin = navigator.plugins["Shockwave Flash"];112
if (plugin == undefined)113

{114
return false;115
}116
var ver = navigator.plugins["Shockwave Flash"].description.split(" ")[2];117
return (Number(ver) >= Number(version))118
} else if (ie && typeof (ActiveXObject) == "function")119

{120
//IE flash detection.121
try122

{123
var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + version);124
return true;125
}126
catch(e)127

{128
return false;129
}130
}131
//Catchall - skip detection132
return true;133
}134

135
//Loop through an array of ids to strip136
//Replace the object by a div tag containing the same innerHTML.137
//To display an alternative image, message for the user or a link to the flash installation page, place it inside the object tag. 138
//For the usual object/embed pairs it needs to be enclosed in comments to hide from gecko based browsers.139
stripFlash = function (stripQueue)140


{141
if (!document.createElement)142

{143
return;144
}145
for (var i=0; i<stripQueue.length; i++)146

{147
var o = document.getElementById(stripQueue[i]);148
var newHTML = o.innerHTML; 149
//Strip the comments150
newHTML = newHTML.replace(/<!--\s/g, "");151
newHTML = newHTML.replace(/\s-->/g, "");152
//Neutralise the embed tag153
newHTML = newHTML.replace(/<embed/gi, "<span"); 154
//Create a new div element with properties from the object155
var d = document.createElement("div");156
d.innerHTML = newHTML;157
d.className = o.className;158
d.id = o.id;159
//And swap the object with the new div160
o.parentNode.replaceChild(d, o);161
}162
}163

164
//Initiate the function without conflicting with the window.onload event of any preceding scripts165
var tempFunc = window.onload;166
window.onload = function()167


{168
if (typeof (tempFunc) == "function")169

{170
try171

{172
tempFunc();173
} 174

catch(e)
{}175
}176
objectSwap();177
}2.这个来源与codeproject,我在开始处放上了示例代码
1

/**//**2
xpengfee search it from http://www.codeproject.com at 2007-08-243
The place which you put flash,replace it with the code below4
5
<SCRIPT LANGUAGE=JavaScript src='InsertFlash.js'></script>6
<DIV id="ad60493"></div>7
<SCRIPT LANGUAGE=JavaScript>8
ActivateFlash('ad60493',FlashAdText('/script/admentor/images/Dundas_Chart_468x60.swf',9
'http://www.codeproject.com/specials.asp?id=3025',10
'/script/admentor/images/Dundas_Chart_468x60v2.gif',11
468,60));12
</script>13
*/14
var FlashDetected = 0;15
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] &&16

navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
{17
if (navigator.plugins && navigator.plugins["Shockwave Flash"])18
FlashDetected = 1;19
}20
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 &&21
(navigator.userAgent.indexOf("Windows 95")>=0 || 22
navigator.userAgent.indexOf("Windows 98")>=0 || 23

navigator.userAgent.indexOf("Windows NT")>=0))
{24
document.write('<SCRIPT LANGUAGE=VBScript\> \n');25
document.write('on error resume next \n');26
document.write('FlashDetected = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n');27
document.write('if ( FlashDetected <= 0 ) then FlashDetected = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');28
document.write('if ( FlashDetected <= 0 ) then FlashDetected = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');29
document.write('if ( FlashDetected <= 0 ) then FlashDetected = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');30
document.write('if ( FlashDetected <= 0 ) then FlashDetected = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")))\n');31
document.write('</SCRIPT\> \n');32

33
}34

35
function FlashAdText(FlashAdMovie, FlashAdRedirURL, FlashAdAltImage, FlashAdSizeX, FlashAdSizeY)36


{37
var FlashAdText = '';38

if ( FlashDetected )
{39
FlashAdText += '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';40
FlashAdText += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0" ';41
FlashAdText += ' WIDTH=' + FlashAdSizeX + ' HEIGHT=' + FlashAdSizeY + '>';42
FlashAdText += '<PARAM NAME=movie VALUE="' + FlashAdMovie + '?clickTAG=' + FlashAdRedirURL + '&target=_blank">';43
FlashAdText += '<PARAM NAME=quality VALUE=high>'; 44
FlashAdText += ' <EMBED src="' + FlashAdMovie + '?clickTAG=' + FlashAdRedirURL + '&target=_blank" quality=high';45
FlashAdText += ' WIDTH=' + FlashAdSizeX + ' HEIGHT=' + FlashAdSizeY;46
FlashAdText += ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';47
FlashAdText += ' </EMBED>';48
FlashAdText += ' </OBJECT>';49

} else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
{50
FlashAdText += '<a href="' + FlashAdRedirURL + '" target="_blank"><IMG SRC="' + FlashAdAltImage + '" WIDTH=' + FlashAdSizeX + ' HEIGHT=' + FlashAdSizeY + ' BORDER=0></a>';51
}52
return FlashAdText;53
}54

55
function ActivateFlash(DivID, text)56


{57
var d = document.getElementById(DivID);58
if (d) d.innerHTML = text;59
}3.这个则是浏览http://www.telerik.com网站时找到的
1

/**//**2
xpengfee search it from http://www.telerik.com at 2007-08-243
The place which you put flash,replace it with the code below4
5
<script src='http://www.telerik.com/scripts/swfobject.js' type='text/javascript'></script>6
<div id="flashcontent">This text is replaced by the Flash movie. </div> 7
{ 这一段相当于在为放置flash文件而准备的一个holder.为放入内容而准备的.如果你没有装flashplayer.那么里面的那行字会显示出来如显示为”This text is replaced by the Flash movie.” 8
如果你装了flashplayer,那这行字是不会显示的,同时它还有一个好处是你可以把这行内容变成的你搜索关键字,google会很容易搜到它的.呵呵,一举两得.}9
<script type="text/javascript">10
var so = new SWFObject("../images/menu-n.swf", "mymovie", "166", "219", "6", "#fff");11
so.addParam("wmode", "opaque");12
so.write("flashcontent");13
</script> 14
15
* SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/16
*17
* SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:18
* http://www.opensource.org/licenses/mit-license.php19
*20
* **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for21
* legal reasons.22
*/23
if(typeof deconcept=="undefined")24


{25
var deconcept=new Object();26
}27
if(typeof deconcept.util=="undefined")28


{29
deconcept.util=new Object();30
}31
if(typeof deconcept.SWFObjectUtil=="undefined")32


{33
deconcept.SWFObjectUtil=new Object();34
}35
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b)36


{37

if(!document.getElementById)
{ return;}38
this.DETECT_KEY=_b?_b:"detectflash";39
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);40
this.params=new Object();41
this.variables=new Object();42
this.attributes=new Array();43

if(_1)
{this.setAttribute("swf",_1);}44

if(id)
{this.setAttribute("id",id);}45

if(w)
{this.setAttribute("width",w);}46

if(h)
{this.setAttribute("height",h);}47

if(_5)
{this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}48
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();49

if(c)
{this.addParam("bgcolor",c);}50
var q=_8?_8:"high";51
this.addParam("quality",q);52
this.setAttribute("useExpressInstall",_7);53
this.setAttribute("doExpressInstall",false);54
var _d=(_9)?_9:window.location;55
this.setAttribute("xiRedirectUrl",_d);56
this.setAttribute("redirectUrl","");57

if(_a)
{this.setAttribute("redirectUrl",_a);}58
};59

60
deconcept.SWFObject.prototype=61


{62
setAttribute:function(_e,_f)63

{64
this.attributes[_e]=_f;65
},66
getAttribute:function(_10)67

{68
return this.attributes[_10];69
},70
addParam:function(_11,_12)71

{72
this.params[_11]=_12;73
},74
getParams:function()75

{76
return this.params;77
},78
addVariable:function(_13,_14)79

{80
this.variables[_13]=_14;81
},82
getVariable:function(_15)83

{84
return this.variables[_15];85
},86
getVariables:function()87

{88
return this.variables;89
},90
getVariablePairs:function()91

{92
var _16=new Array();93
var key;94
var _18=this.getVariables();95
for(key in _18)96

{97
_16.push(key+"="+_18[key]);98
}99
return _16;100
},101
getSWFHTML:function()102

{103
var _19="";104
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length)105

{106
if(this.getAttribute("doExpressInstall"))107

{108
this.addVariable("MMplayerType","PlugIn");109
}110
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";111
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";112
var _1a=this.getParams();113
for(var key in _1a)114

{115
_19+=[key]+"=\""+_1a[key]+"\" ";116
}117
var _1c=this.getVariablePairs().join("&");118
if(_1c.length>0)119

{120
_19+="flashvars=\""+_1c+"\"";}_19+="/>";121
}122

else
{if(this.getAttribute("doExpressInstall"))123

{124
this.addVariable("MMplayerType","ActiveX");125
}126
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";127
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";128
var _1d=this.getParams();129
for(var key in _1d)130

{131
_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";132
}133
var _1f=this.getVariablePairs().join("&");134
if(_1f.length>0)135

{136
_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";137
}138
_19+="</object>";139
}140
return _19;141
},142
write:function(_20)143

{144
if(this.getAttribute("useExpressInstall"))145

{146
var _21=new deconcept.PlayerVersion([6,0,65]);147
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version")))148

{149
this.setAttribute("doExpressInstall",true);150
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));151
document.title=document.title.slice(0,47)+" - Flash Player Installation";152
this.addVariable("MMdoctitle",document.title);153
}154
}155
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version")))156

{157
var n=(typeof _20=="string")?document.getElementById(_20):_20;158
n.innerHTML=this.getSWFHTML();159
return true;160
}161
else162

{163
if(this.getAttribute("redirectUrl")!="")164

{165
document.location.replace(this.getAttribute("redirectUrl"));166
}167
}168
return false;169
}170
};171
deconcept.SWFObjectUtil.getPlayerVersion=function()172


{173
var _23=new deconcept.PlayerVersion([0,0,0]);174
if(navigator.plugins&&navigator.mimeTypes.length)175

{176
var x=navigator.plugins["Shockwave Flash"];177
if(x&&x.description)178

{179
_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));180
}181
}182
else183

{184
try185

{186
var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");187
}188
catch(e)189

{190
try191

{192
var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");193
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";194
}195
catch(e)196

{197
if(_23.major==6)198

{199
return _23;200
}201
}202
203
try204

{205
axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");206
} 207

catch(e)
{}208
}209
if(axo!=null)210

{211
_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));212
}213
}214
return _23;215
};216

217
deconcept.PlayerVersion=function(_27)218


{219
this.major=_27[0]!=null?parseInt(_27[0]):0;220
this.minor=_27[1]!=null?parseInt(_27[1]):0;221
this.rev=_27[2]!=null?parseInt(_27[2]):0;222
};223

224
deconcept.PlayerVersion.prototype.versionIsValid=function(fv)225


{226

if(this.major<fv.major)
{return false;}227

if(this.major>fv.major)
{return true;}228

if(this.minor<fv.minor)
{return false;}229

if(this.minor>fv.minor)
{return true;}230
if(this.rev<fv.rev)231

{232
return false;233
}234
return true;235
};236

237
deconcept.util=238


{239
getRequestParameter:function(_29)240

{241
var q=document.location.search||document.location.hash;242
if(q)243

{244
var _2b=q.substring(1).split("&");245
for(var i=0;i<_2b.length;i++)246

{247
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29)248

{249
return _2b[i].substring((_2b[i].indexOf("=")+1));250
}251
}252
}253
return "";254
}255
};256

257
deconcept.SWFObjectUtil.cleanupSWFs=function()258


{259

if(window.opera||!document.all)
{return;}260
var _2d=document.getElementsByTagName("OBJECT");261
for(var i=0;i<_2d.length;i++)262

{263
_2d[i].style.display="none";for(var x in _2d[i])264

{265
if(typeof _2d[i][x]=="function")266

{267

_2d[i][x]=function()
{};268
}269
}270
}271
};272

273
deconcept.SWFObjectUtil.prepUnload=function()274


{275

__flash_unloadHandler=function()
{};276

__flash_savedUnloadHandler=function()
{};277
if(typeof window.onunload=="function")278

{279
var _30=window.onunload;280
window.onunload=function()281

{ 282
deconcept.SWFObjectUtil.cleanupSWFs();283
_30();284
};285
}286
else287

{288
window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;289
}290
};291

292
if(typeof window.onbeforeunload=="function")293


{294
var oldBeforeUnload=window.onbeforeunload;295
window.onbeforeunload=function()296

{297
deconcept.SWFObjectUtil.prepUnload();298
oldBeforeUnload();299
};300
}301
else302


{303
window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;304
}305
if(Array.prototype.push==null)306


{307
Array.prototype.push=function(_31)308

{309
this[this.length]=_31;310
return this.length;311
};312
}313
var getQueryParamValue=deconcept.util.getRequestParameter;314
var FlashObject=deconcept.SWFObject;315
var SWFObject=deconcept.SWFObject;