|
楼主 |
发表于 2008-1-8 22:28:00
|
显示全部楼层
回复:对比国内门户网站对Flash激活限制的处理
IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法。0 V! j' Z- e* R2 h9 N
9 H( T1 v7 e+ ]# X& S% r3 M当鼠标移到网页中的FLASH上时,会出现一个外边框。并有“单击以激活此控件”的提示。解决方法:, y+ q) T! h2 L
5 P, s6 N9 I4 _
1、新建JS文件:. A4 P; a7 T' g" h- b
. \& L! y4 W6 ^" a//v1.08 R, O' H4 i; d7 ~# q
//Copyright 2006 Adobe Systems, Inc. All rights reserved." @; e0 G% Y+ z
function AC_AddExtension(src, ext)
6 U; T% O: u6 b' I4 P! J8 A{# q" {" S4 q* N
if (src.indexOf('?') != -1)0 g/ \* I* [4 N4 f
return src.replace(/\?/, ext+'?'); 8 K( Q V: R- h+ ~1 y! q: p
else
, {# ~4 \8 @) d. K7 W2 X return src + ext;9 u! g+ {5 J( V0 x, h
}
- z$ _8 W" u: x2 Q p F+ [+ @9 ~& ^1 C# k( O; A. x
function AC_Generateobj(objAttrs, params, embedAttrs) . H0 K! s0 q/ D4 P7 f. o
{
9 v- A$ r, ^! c: z" Q8 ~% o8 t var str = '<object ';
2 h( ^$ `0 A- b' m1 d1 w4 ]5 a2 ? for (var i in objAttrs)
) D9 @& M& p3 o; h7 t str += i + '="' + objAttrs + '" ';
, D1 y" N8 i( q! t0 s0 T Z) t str += '>';
) V/ R Y: q/ Z: q. O for (var i in params)& A% N' w, N$ ^, ~9 I0 V9 Z. X$ T
str += '<param name="' + i + '" value="' + params + '" /> ';7 z7 q7 _9 u- _; `8 i6 Y
str += '<embed ';
/ N3 Q6 Q" ^ i# F for (var i in embedAttrs)
) Z+ u p( p2 Y9 n: i str += i + '="' + embedAttrs + '" ';
' p. a4 p6 |% `$ Q* ?. ] str += ' ></embed></object>';
, d( Y( q! g3 {. l0 x6 a( c% f) `' i. Q4 I0 p. Y5 _
document.write(str);
3 \& g! p# W0 R9 z9 R4 k}
/ L# R; `8 m# J
4 W3 A# w& b" [5 Mfunction AC_FL_RunContent(){2 S5 _& R1 h' J4 V4 |* }
var ret =
. ^- S* ?$ V* M& a AC_GetArgs
7 Y/ z0 U; y4 U( Y: [7 h ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
7 O, M+ }# j+ H$ i7 Q , "application/x-shockwave-flash"
1 w# t9 m, v- o: r+ |( i );& W& {1 g+ W! ~: Y) c" R9 c- V! i
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
. g1 G+ o9 U4 Y: D}) q. T9 H) r2 h/ i$ D$ ?5 C: y
7 H. Y- d) ?$ @# E2 Z5 Dfunction AC_SW_RunContent(){
& m) a8 \0 X- [3 w var ret = 3 O9 |$ E' P, |2 i V
AC_GetArgs: U+ V, r0 X; a F1 s
( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"! f, i" N6 u7 C# D) N( x, R
, null
3 e: W; n% P9 s( O );/ ^) ?! I; f5 l7 \+ d2 t- Y5 @
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
" x- z4 \0 ~) E}! l) W1 O% d- d9 Z2 n& g
" V3 B ?* g6 ^ I/ R
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
; F ]+ }# B: ]- ]2 N* L var ret = new Object();
& X x: ~& Q4 J1 K ret.embedAttrs = new Object();8 K# ]) r1 ~0 `! v' B/ G0 H% s
ret.params = new Object();
4 k6 P6 H- @* p ret.objAttrs = new Object();
& `& B* }2 s9 a& U" a8 L( u" v for (var i=0; i < args.length; i=i+2){* w c- ^( R# E2 L1 r' x/ Y
var currArg = args.toLowerCase();
4 T; P. x5 j- ]4 A, [; w, }
6 L, t# I6 @. f. }$ m, f" G1 U switch (currArg){ , I: n: \+ ?" V" ]! H# u/ \
case "classid":" j! P; M& B. Z2 }
break;: D* [, m' |! S
case "pluginspage":; J; j: m4 i, V9 C6 C" z) a
ret.embedAttrs[args] = args[i+1];
( Y/ l& w0 k2 D8 ] break;
4 }8 }2 l! x) w @; Q: [2 j case "src":
! K p C! [. E5 x6 e- d8 P6 v case "movie": * G/ J$ ~( V8 N! e
args[i+1] = AC_AddExtension(args[i+1], ext);
6 Y; U* L2 H0 g& X( {" z ret.embedAttrs["src"] = args[i+1];8 H4 [- @& D4 F
ret.params[srcParamName] = args[i+1];
( n" f6 Z2 ~3 E: o, b" t8 S% o+ W break;
8 @% k0 [6 s6 h' u# n1 l0 @* ]9 \ case "onafterupdate":
) Z1 c( A2 }( L) n. _- _ case "onbeforeupdate":- ~7 O7 J2 R; c( F- m& u; B
case "onblur":
! ?8 D, P& S: t; `- t4 m case "oncellchange":
# J! E4 }% y0 F- k* Q case "onclick":# R- @7 S' s- } t
case "ondblClick":) m# m0 b' d; s1 u% \$ X7 t
case "ondrag":
" d% \ c& l5 L$ }9 [ case "ondragend":
- ?& ~ P7 b/ L! Y case "ondragenter":2 B! _( N4 ]1 P3 ]9 c1 \
case "ondragleave":1 f- }1 Z3 E( _ }0 U! R+ o
case "ondragover":- R& p) f( _. [& H. M7 `4 y
case "ondrop":+ t+ z9 x" ]1 a* U& l; f O/ R7 N+ A( ?
case "onfinish":/ u' J& ^& K% b+ _% J( ]3 y
case "onfocus":
- S! d- i: r, b5 K U6 q1 ` case "onhelp":3 g* M9 s" _( ? C3 \+ m
case "onmousedown":
: V% n/ Y! K9 n8 w* A9 R8 p7 N" T case "onmouseup":
. Q* \1 M3 r* H case "onmouseover":6 D5 E5 L! A, n- I6 T# M- b
case "onmousemove":
& @ A5 @/ q0 _- M$ z case "onmouseout":0 R: W1 `" X: O) M; D* v9 x* A5 s
case "onkeypress":) _; @. J* Y; V
case "onkeydown": [! r i3 u7 M6 u3 [; u/ l
case "onkeyup":
+ H* n: z/ m/ c6 y+ G& g) \& X case "onload":
: C. E2 k4 k+ h( p7 @. r; {: O case "onlosecapture":
" }6 @9 W- o7 t7 v! J. r case "onpropertychange":
& T8 @% F, c: a1 I6 j; i. e% ~ \ case "onreadystatechange":5 l; M u Z+ U' L# N
case "onrowsdelete":: h1 |$ O9 k Y# @
case "onrowenter":
/ A1 A" g0 m* F case "onrowexit":
: k: B% V: |' G. A2 {4 M2 J: h case "onrowsinserted":- t& G9 c8 ?- q K
case "onstart":
a" ?! m9 J3 |3 y% U case "onscroll":
* P; X/ c/ G' h case "onbeforeeditfocus":) e# |: J& g1 p; M
case "onactivate":( v0 d, v5 Q# J, W5 |1 }
case "onbeforedeactivate":% J$ Z& [$ m& W1 A8 Y& |$ F
case "ondeactivate":. m$ ~; z6 R2 O) a! U) Z: ]
case "type":3 t! M" c* m& E- t! ]: j6 y3 O
case "codebase":# N8 `# ~6 v! p" g
ret.objAttrs[args] = args[i+1];
- z# T' r: X0 a: m7 j3 u4 M! G break;
$ P2 V5 h7 |" Y. Y& z case "width":0 n- ~4 ]( [2 E% ]+ G
case "height":
6 g5 Q$ m4 Z5 p case "align":
5 y% q4 D3 {8 J case "vspace":
* F1 B+ }4 J. }2 C% B; O u case "hspace":- W/ q) B- T: e9 ]
case "class":7 a$ t& N4 h D* l
case "title":
( {6 D! n3 ?" j5 W' u case "accesskey":
1 u8 N: L4 Q" E# U& h' K: I9 D5 d+ o case "name":
9 B) W1 O' l/ t$ z3 D3 c+ f* m case "id":
+ _8 Y! s# f7 p0 A" ]- w* b case "tabindex":
5 {/ b7 M1 s$ Y/ H! S ret.embedAttrs[args] = ret.objAttrs[args] = args[i+1];
1 k! L) o9 Z g7 x, g7 H8 s break;
- }# G& n+ M5 \- g default:# O, K' h" F! z, ?8 X b7 \) y: X
ret.embedAttrs[args] = ret.params[args] = args[i+1];
: U9 X3 L" O- l/ L }: U$ a. I, M: f" N
}
" N+ O% E. o8 B9 J4 k$ k% l6 ^7 f' m ret.objAttrs["classid"] = classid;
1 k0 H4 X5 L/ t" W$ R; a! q- I if (mimeType) ret.embedAttrs["type"] = mimeType;
5 S( U* x! G O* n8 \0 K return ret;
D. Y" b, K- K}- s+ ~+ ?! E* n- o
$ l; e8 a# O8 w. `. b8 r9 M
2、保存为:AC_RunActiveContent.js
, |3 k/ q2 C8 e: T; @. Y: l- r: _) X/ g* w4 b
3、在所需的页面中添加;
& T0 b; ^4 E# `3 p B
: ~$ l6 K6 F$ N% n& f5 b) }1 R) {$ q<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
! ]4 S" P4 D# T! {, G' ~; f1 q" Q2 y) u! E x
4、在插入FLASH的位置添加:
7 Y- P. w4 d6 n0 O: X/ y) v0 ^: v. t
f# ~' G: O5 j. r<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># q; |9 p2 r! G& y$ l
<noscript>( o# Q P( e9 R. T" Q
<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">: Q+ m3 p! P J) n5 V
<param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/index.swf">- j# h( Z) u# a" U" y
<param name="quality" value="high">
( P$ r6 ^$ Q1 ]- D% e2 D& y<param name="wmode" value="transparent">1 N1 K# A9 Z7 k/ X% \
<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>
, ?& o% F, T7 P3 W+ G</object>/ O' P& E" ^, n3 r. E0 G
</noscript>
0 V7 c; Y7 G ?6 L" ~. Z+ g0 x9 N5 Q; M1 Q0 h. o8 h I- h
5、页面中的完整代码:
, A* `5 I0 G2 |3 j& P7 l& k4 J# A7 \7 \! s$ u; }1 { C
<html>5 f2 n/ o2 l5 V; {) P( A0 n
<head>
4 }- l3 ~4 Q7 P<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
# `# l- g8 }7 n$ d" G9 E/ X<title>IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法</title>
- E; u d) }( a5 ~) ]<!--加载AC_RunActiveContent.js,此为DW自动生成的文件,无需修改,更改文件目录的时候记得修改这里的路径-->
9 t+ J7 [$ H$ p4 o; D<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>* D* R1 d5 D; \/ F6 K1 x" G
<style type="text/css">4 C& A" l" H; k( d' |* m
<!--# n, v4 x a5 h- G9 `
body {
0 l3 W' } s% k background-color: #CCCCCC;
& s3 X7 c% y# O8 w a/ A7 h}
8 \1 Y7 U; c( ]$ c: A9 }8 o-->5 P- [' T: ]9 @6 X
</style></head>5 J: J; G1 x5 t3 k1 U
<body>
3 o. c4 i) ]: I1 a V7 v& ?9 D" `$ h0 c1 X; G* T+ w8 z( k
<!--下面这段JS修改的时候要注意,一共要修改四个地方:
1 C; Y! d6 e" B300 是宽度;* L7 ]# D8 Y; L4 }2 D2 e# D
200 是高度;7 B5 u' b9 [2 t
images/killIEBorder 是路径和文件名,修改时注意,共有两处,还要特别注意,文件名后面不要加“.swf”,此后缀已经写在AC_RunActiveContent.js中-->
8 y" _7 v0 @6 [8 G, U<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>
/ O/ b7 d+ h) `) Q7 x<!--遇到浏览器禁用javascript时将调用下面这段<noscript></noscript>内的代码,就是Dreamweaver升级到8.0.2之前我们插入flash时的那段代码。<param> 标签针对IE起作用,<embed> 标签针对Firefox和Netscape起作用。-->( ?, ~) y3 J5 J! ~5 ~+ t* _
<noscript>; u: \9 k1 V# F
<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">4 p+ V' M4 T" l8 b
<param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/images/killIEBorder.swf">+ L( m0 G% g! G2 |6 X6 v
<param name="quality" value="high">
4 k( O2 ^! |* X) y/ q" X4 u/ R, E <param name="wmode" value="transparent">
$ k6 T$ b' o4 F& h! W( a <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>
% s& F! z, j) h9 v Z</object>
} ?8 }, C7 H+ p! B</noscript> |
|