|
楼主 |
发表于 2008-1-8 22:28:00
|
显示全部楼层
回复:对比国内门户网站对Flash激活限制的处理
IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法。+ X/ v- _3 u- b- |
) q) c% g: y8 r; H当鼠标移到网页中的FLASH上时,会出现一个外边框。并有“单击以激活此控件”的提示。解决方法:
( O; I) c! z2 {, T: D, N
5 z+ K2 \, Q2 m' i5 W1、新建JS文件:
. J P( h" J9 C" @2 E
7 M# B+ p- {7 i' u7 K' K# V0 d: m//v1.0
: Q) E5 n2 ?/ _+ \; v( M. \//Copyright 2006 Adobe Systems, Inc. All rights reserved.
; q _9 w7 x" k! I8 E( e% z5 k9 yfunction AC_AddExtension(src, ext)
; l6 o6 m/ P; G1 |/ S! _8 p: D% P/ X{- @9 m! E0 z6 k* i
if (src.indexOf('?') != -1)
. ^& w8 ?& X2 n$ {& K. V- g return src.replace(/\?/, ext+'?'); 9 N( r7 b4 z, `$ V; i, \! u1 W
else- m/ C- {: r" s) J( w. I- @
return src + ext;
m1 f9 k0 C. ?( {" o}
* e: t( E/ E, g/ `! S! n; w
' ~" c( I6 ^9 F3 E/ F3 T0 }function AC_Generateobj(objAttrs, params, embedAttrs) 4 Y, {1 W5 T3 A$ c2 A; y3 f
{
8 ?6 z- c9 J5 g; w& ` var str = '<object ';: A6 a8 c9 M4 Q9 |3 @
for (var i in objAttrs): o" v5 G. v" n" ?7 ~
str += i + '="' + objAttrs + '" ';
0 K2 K" ^3 v! x/ {2 } str += '>';
9 t! c, \5 H6 D2 O for (var i in params)5 p5 ?: w+ ]& o' m. m; W1 F
str += '<param name="' + i + '" value="' + params + '" /> ';' M) e( s0 G- M/ a0 H& ]! d# Y! x
str += '<embed ';
) d- f' z$ i$ C" A* F: B for (var i in embedAttrs)8 o+ m, Z4 y$ v$ W( [8 i R
str += i + '="' + embedAttrs + '" ';4 W+ y% C- }8 G& p _0 d4 V
str += ' ></embed></object>';
9 z7 b8 l2 ?$ r: s; w5 i
9 T% k5 |1 y4 S& r0 g document.write(str);
( W% p Z' z/ Y1 j9 H}
0 ]0 ^$ e9 J0 g
5 N1 D" i/ S! b8 r5 ofunction AC_FL_RunContent(){+ z+ `; r2 G8 Y& Q: H4 {
var ret = U+ g9 E9 A* S& i: B1 L p) N) z: Z
AC_GetArgs5 O! h! q5 S0 {; b; b3 |0 n5 |
( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"* J/ R8 X7 F! y/ ]
, "application/x-shockwave-flash"
' n$ W; I+ }7 H* ?$ h5 i0 s! C5 g# n- [ );* f4 h5 N* U# B+ g* [
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);" V$ U; w: k' Z" N8 ], R" m
}$ A* _/ Z: _, `- N
' W9 I3 c% s( N+ D! p2 M& Z
function AC_SW_RunContent(){
) q* E* U, _4 X var ret = H3 u6 G' Y4 s0 [. D
AC_GetArgs
) R& K+ t, N8 i ( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
* N. y1 s- b5 `2 ~! c2 y3 { , null
( \" Z5 |" R2 A) `* @$ h& u7 p );
# q( m- Q4 a- G; O9 s8 ~ AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
" I6 F. N5 K# S4 W; J" a}% {8 o3 [ H& k: F
$ t" b& B$ h5 n) n1 yfunction AC_GetArgs(args, ext, srcParamName, classid, mimeType){
% V, z6 i7 ~% c: m7 f6 b var ret = new Object();6 x$ F& s2 a! \- o* i
ret.embedAttrs = new Object();
% S* P7 x2 Z- e' a1 e) Q ret.params = new Object(); b% K' B! r7 R, l8 v4 e4 N: J
ret.objAttrs = new Object();6 p* b! i2 G: _& i5 f/ C3 B2 T
for (var i=0; i < args.length; i=i+2){$ T$ m. }8 d: q8 A l
var currArg = args.toLowerCase();
- Q" s$ s: @$ r G1 f
- i: o2 ~. T0 `% Z# T switch (currArg){
' i- b, b n7 F k case "classid":
, `/ y3 e( I9 E P" V break;
3 I- Q! e3 A& e7 d8 z case "pluginspage":
" m4 p2 ?: P$ f. Z W, v% y ret.embedAttrs[args] = args[i+1];
0 @9 K* R: n: g1 f' W9 a. n( W7 F break;
: i8 z/ ?# F, U9 d3 |9 `- \ case "src":) U8 E4 r$ p2 H% d6 N1 W5 K7 g
case "movie": " l. j2 @1 a& o: a. H$ b9 Q
args[i+1] = AC_AddExtension(args[i+1], ext);
1 j9 h# }$ O" H4 `2 C" x ret.embedAttrs["src"] = args[i+1];
% P+ w( D) \( K/ Z3 p6 J ret.params[srcParamName] = args[i+1];
7 [/ O' v! ]. n break;9 E! [* {8 s7 y( h! Y8 q' m2 x
case "onafterupdate":
) c$ V, Z7 t# c case "onbeforeupdate":
. ?4 a- _. V$ a3 ?+ r! [ V case "onblur":; ?2 N* l- O! X% N. K( N: B
case "oncellchange":
6 _4 G" K3 o/ k5 C9 U case "onclick":5 q k0 w+ a9 g2 [5 ]* F& E) }1 L
case "ondblClick":5 p+ |$ y! a* ]! n2 x9 H
case "ondrag":
& {2 n% y1 r/ A8 ~3 N e3 H$ E1 s case "ondragend":
: e6 H0 \; X; e% Z- w case "ondragenter":
( j* i4 n. \5 A9 h8 Q case "ondragleave":, B) m) J5 w" u- c c+ f* K
case "ondragover":
g3 Q2 v! Y3 \& i: U% _0 Y" R case "ondrop":
+ |/ Q U+ K7 ` case "onfinish":4 ~8 | q) a, D2 ^. D4 l1 q
case "onfocus":1 M! u8 M. M& u) b3 [
case "onhelp":, j- x$ F2 |' z
case "onmousedown":' s C- T. [* u/ s* y8 @* V: Q& s
case "onmouseup":
) \1 i7 ]9 k: X2 F+ ?; F case "onmouseover":
' T6 Z6 G0 E; e6 } case "onmousemove":
/ m2 b' b- {( b0 h; C9 z case "onmouseout": r& I9 w4 @3 f. h b) B
case "onkeypress":
/ n6 k! x+ m$ A9 A: c case "onkeydown":8 v4 {: T9 r$ I
case "onkeyup":) e8 p& e5 e& a9 O! u6 z, f
case "onload":2 ]6 h2 A3 Y* H. e8 l4 I
case "onlosecapture":
8 Y2 h, I: h/ D7 D `4 A case "onpropertychange":
8 g" c5 n$ T; ^# b" T c case "onreadystatechange":
$ p. L! e5 {% P! F) s case "onrowsdelete":6 ?2 R7 O1 C- p5 n' [2 h
case "onrowenter":
$ f+ [) q7 E( x' ?1 f% w9 N8 s! X case "onrowexit":7 V* |, }5 x# V
case "onrowsinserted":
! x# I/ V1 o0 z case "onstart":, z+ F) ^( d$ s
case "onscroll":
: Y- E2 }! C- y case "onbeforeeditfocus":! X; m+ {1 }( T- O) t& {$ d! }
case "onactivate":& s, {# {2 C# G8 Z, i3 F' V- k4 r
case "onbeforedeactivate":8 C' d+ X* M% c; h1 O
case "ondeactivate":7 e r) g; J H1 `/ k: g
case "type":+ e _1 _4 B/ X* ]1 Q5 a7 v
case "codebase":
8 T* l6 I; F9 h- I% Z2 [# Z ret.objAttrs[args] = args[i+1];$ l: ~5 I7 G | K/ E+ U
break;
# V# r5 m6 E0 X. r. W case "width":
9 m' M9 n" N$ ?& e* k7 m9 [ case "height":
; a% B5 V [) w) ~% @" |2 j5 T. ?: | case "align":
% Y7 e) {1 k# B; k case "vspace":
& \; E7 z/ F- g case "hspace":4 ?# M; B6 W: _! m! n
case "class":6 Q( F& s/ R5 K1 R$ u7 _3 O; c7 b
case "title":0 I5 ~) m; B3 D- H; c, b3 l
case "accesskey": D' m& O7 V4 w2 u, E% g9 i
case "name":0 Z$ M" y6 X& t( D" l Q: l3 Q$ p
case "id":% N8 G" k" _: w1 J9 A. H
case "tabindex":; Z0 P* _/ I- B7 f. z
ret.embedAttrs[args] = ret.objAttrs[args] = args[i+1];
6 X; T9 C" R+ M2 R& H/ m* D break;
" ~. T+ h/ M% t% @ m$ V. t7 e default:
7 n/ D9 ]* Z! z4 x* f2 v+ n ret.embedAttrs[args] = ret.params[args] = args[i+1];) o$ b% G# G: D# Z p9 A
}/ h; d, q+ A5 W! Y, u3 s+ v
}
4 S# g! E. s5 a1 d# B* B% X ret.objAttrs["classid"] = classid;* G7 \# k5 f& |$ V% v8 R- q$ e! _
if (mimeType) ret.embedAttrs["type"] = mimeType;; [; q# r; T/ J! c) g& |+ d
return ret;
! w! q' [. ~, I. d F9 Y( `}
1 u1 I3 M7 ]" n( c; j9 L/ x/ F- g% C9 J0 w9 J
2、保存为:AC_RunActiveContent.js5 b* W- J9 p9 w' e
- z. |% j2 T( x* X* u/ u; C4 @
3、在所需的页面中添加;
5 w; `5 Y. r( C& U8 ^9 p
' r2 ^. P6 K; d, I5 }' u- i& Q<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
+ d2 ?2 S( r0 v A1 y! V
4 y) }. }% f0 z& M5 Z% j4、在插入FLASH的位置添加:
! k2 K/ ^, s# `+ C
, Q; i* u/ D/ p<script type="text/javascript">AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','1002','height','600','src','index','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','index' ); //end AC code</script>, w! w% A3 \7 l$ z8 _9 q/ z* }
<noscript>
! {2 A8 J5 \) l( [& C<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="1002" height="600">; n4 O! ^6 s. ]2 d" r4 [+ }# z
<param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/index.swf">
. O; R7 r, t" f/ p4 s; U<param name="quality" value="high">
6 X9 ~! H$ }# Q: j3 ^4 v0 u/ l4 G<param name="wmode" value="transparent"># a9 {7 k0 q& P5 v. A, \, R
<embed src="http://www.webjx.com/htmldata/2007-04-22/index.swf" width="1002" height="600" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>
2 s0 Q* B7 \6 t4 B( b; O5 S</object>
* Y W8 Y; e& [" G# S</noscript>
" }, ]9 A/ c7 @ B0 K* ?. z u1 t/ s$ b0 O
5、页面中的完整代码:
+ R, Z s4 B) ^$ a' \7 f# e) M# b7 \' m' P
<html>* E8 ?5 D ?9 F0 T7 c# i" b w
<head>7 H" l) E' j: p( a$ _' c' I$ Z
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
# u& `2 [5 N1 ?3 T- X4 ]<title>IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法</title>3 `7 z5 K! O& T/ B! x r* b7 x
<!--加载AC_RunActiveContent.js,此为DW自动生成的文件,无需修改,更改文件目录的时候记得修改这里的路径-->; p4 l$ t. W2 x& E3 C* D R. Y
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
8 N* X0 Q4 H% y0 f<style type="text/css">: n- j$ C" p0 |3 }
<!--' D1 {1 Z1 P" o e' {0 ^) q
body { W! @$ S8 q. P$ m; Q. p2 m
background-color: #CCCCCC;* Z6 l' B; i+ e: z9 h
}
! R3 i; W2 c- r" L1 q-->
% |; L) a" R6 j0 o- ?$ ~4 i</style></head>
- v: _0 R1 w4 B<body>+ V$ y6 F# @ D; a2 J
8 q( d9 B, H$ l7 S Q<!--下面这段JS修改的时候要注意,一共要修改四个地方:
$ Y0 m- P) L" J7 ~300 是宽度;
0 z0 P; | d& o& ^7 n6 C5 h200 是高度;9 V* r* I* T7 j4 b5 o2 s% N, t
images/killIEBorder 是路径和文件名,修改时注意,共有两处,还要特别注意,文件名后面不要加“.swf”,此后缀已经写在AC_RunActiveContent.js中-->5 n2 C8 J' E# g/ C( Q
<script type="text/javascript">AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','300','height','200','src','images/killIEBorder','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','images/killIEBorder' ); //end AC code</script>
2 E+ ]' f( H7 D: a$ r* o<!--遇到浏览器禁用javascript时将调用下面这段<noscript></noscript>内的代码,就是Dreamweaver升级到8.0.2之前我们插入flash时的那段代码。<param> 标签针对IE起作用,<embed> 标签针对Firefox和Netscape起作用。-->9 a) x/ _: H5 B9 l; @3 ?5 k$ ]
<noscript>9 ?! P1 g2 m C
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="300" height="200">
6 p J3 W3 f- {/ }! U <param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/images/killIEBorder.swf">
5 S+ P2 z4 F) Y( @2 F- e/ T <param name="quality" value="high">- M: A3 b1 |; K7 N! s
<param name="wmode" value="transparent">9 G/ \2 H$ U+ ]8 b t; Y8 U7 W
<embed src="http://www.webjx.com/htmldata/2007-04-22/images/killIEBorder.swf" width="300" height="200" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>
+ d& r3 |( s& E: W</object>/ A8 V& E( K2 J5 A
</noscript> |
|