|
楼主 |
发表于 2008-1-8 22:28:00
|
显示全部楼层
回复:对比国内门户网站对Flash激活限制的处理
IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法。8 _3 e2 _, e" F
& S$ j) ^4 A6 W/ ~: r; K
当鼠标移到网页中的FLASH上时,会出现一个外边框。并有“单击以激活此控件”的提示。解决方法:$ y" x; B$ X1 s
' Y5 m) x% L- D. @
1、新建JS文件:9 G/ h, ^6 M" t$ |
. a) F" x2 |) L8 |, [, E; }//v1.0/ N$ Y5 b2 j; H
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
2 N7 `% i: O7 B; |+ C$ zfunction AC_AddExtension(src, ext)! `' ]# w! G; y5 T1 N+ F
{7 {3 L% W3 M" u
if (src.indexOf('?') != -1)" u: {1 Q, r# N
return src.replace(/\?/, ext+'?');
4 g B0 K5 u, l" B) E; E else/ C- D* a' f R1 P O0 Y
return src + ext;
( \. F+ @- K/ h4 Z$ G}& Y( {) S3 O; k
% u0 R- j$ h0 |& e% F- Kfunction AC_Generateobj(objAttrs, params, embedAttrs)
9 Q% @/ B+ A! k( c0 p% b0 n* O. H{ + s) S6 S! V1 c' n7 N8 m7 p4 H
var str = '<object ';
! a8 D+ T) ~% ]' Z8 W for (var i in objAttrs)5 U p: @# n8 q
str += i + '="' + objAttrs + '" ';
^, @" {. ]% ^: a ~% r2 | str += '>';+ H% W, i; B: q: {# k8 ?( e
for (var i in params)8 o. R% J, H; [7 L
str += '<param name="' + i + '" value="' + params + '" /> ';
& K* R* t; D# `1 j& ^ str += '<embed ';+ A; P- j* ?1 t3 g8 @9 f. W
for (var i in embedAttrs)
& r% a. J9 m; S b str += i + '="' + embedAttrs + '" ';
( f6 x7 m2 Q! [9 i str += ' ></embed></object>';* l8 z/ d S( f f3 c& I: ~. [
4 E/ D! z8 T; i+ [
document.write(str);$ m$ F) e& M0 T. c7 a
}3 X# @4 a/ G2 j4 a
) } [3 t, ^# Z/ Y3 rfunction AC_FL_RunContent(){
1 Q$ p! _4 s2 A var ret =
$ Q+ t$ D/ h8 L1 p/ ` AC_GetArgs/ Y; C9 f/ q' L- F4 Z* D
( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"; H. y$ K9 O6 r3 }! x& G
, "application/x-shockwave-flash"
5 q5 {4 |' r% A, d, d* l );
8 Y+ E. \4 A' V AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
* N. d& J; x; y* [2 Y}
+ B4 T9 e. C& ]8 }2 I) l0 s" K3 u$ K+ e1 a% c6 h
function AC_SW_RunContent(){
; z K" C K+ c3 I( d+ s( f) k var ret =
; d( o& n% a s% Q+ ~9 j y AC_GetArgs
) p" x* @% Q9 d- Y6 i! x- | ( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
- z9 \: L3 R, l( c/ u , null
, Y1 v/ \2 V2 G2 y' N( W$ [ );
3 b3 G. u9 z7 ^ AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);" j- W5 Z% x: C5 V8 a) _1 @' u( y
}
/ ?$ _5 x9 U3 L! ^4 s5 T2 ^
) M4 A3 Z7 X6 i+ c$ B. A8 x; |function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
- ~ N7 }9 U% l: h var ret = new Object();
# P9 @+ N3 P* Y6 E9 a7 I4 ~ ret.embedAttrs = new Object();, A2 z6 S- y2 c
ret.params = new Object();' Q% V4 f; F- l# N' G
ret.objAttrs = new Object();+ j! h0 o' s: K3 i2 Q. R4 o
for (var i=0; i < args.length; i=i+2){9 S; W; o! H% q: x# H
var currArg = args.toLowerCase(); . o' G6 h9 s9 D5 C
" _; V# R$ R: Q1 Q1 i. b9 t0 `2 F
switch (currArg){ & l5 J' ]$ w `+ c
case "classid":
2 l1 p- ]2 H0 x7 C1 ?- {3 v break;
) z B" N7 c) X, \# Z" H case "pluginspage":
$ D* {9 C o( k2 _2 @3 k3 M9 U' M a ret.embedAttrs[args] = args[i+1];' ] H" E; d. `* q$ `1 x
break;6 S5 H* Q, v' I7 K
case "src":* t. m' n% u- y2 p) v! X
case "movie":
( i& d; A3 M: d. K0 a0 Y6 X args[i+1] = AC_AddExtension(args[i+1], ext);) \' o+ w$ ~. w: |1 t
ret.embedAttrs["src"] = args[i+1];& E# L) j' P& z" _/ L
ret.params[srcParamName] = args[i+1];0 @$ {) p, Q5 t; c6 d
break;$ K$ Z j1 n( M# u P* |3 T
case "onafterupdate":
( @# O6 J7 [: `% ~5 O( y/ t case "onbeforeupdate":
! t4 c7 j% E$ T0 z" Z7 C& _ case "onblur":0 l, Z/ {4 w2 W i! q) t6 m! a5 f' Y1 f- r
case "oncellchange": k( U8 Z& J7 U, B* U
case "onclick":
& ?* s5 Q" L5 S0 `$ w+ Y& ^: S case "ondblClick":/ @, M: z* l+ g8 C9 [# m
case "ondrag":" ~3 l! `4 ^0 S- i _# N9 m
case "ondragend":6 o4 Y5 M. U( R. C2 U0 o4 V
case "ondragenter":
) B( c) t# o, y& Q$ p, T, }& V8 D1 D case "ondragleave":$ m. q- N+ ]3 ]- K# z' E0 c
case "ondragover":$ H% f7 V5 Z* E9 K! s, U) Y
case "ondrop":
) w" L. H, G4 k* i: Z case "onfinish":8 V) z4 J( V# l6 a/ a8 @
case "onfocus":! R7 x9 N+ k( j3 ?) a
case "onhelp":
3 I6 ^# b& f& P6 V2 _, } case "onmousedown":
% C9 F9 p; b1 \$ t case "onmouseup":
" Q/ U: Z; H8 L/ w/ ` case "onmouseover":
+ \3 g! \; C5 O u case "onmousemove":
4 A2 B' j7 ]& Z+ i0 l case "onmouseout":6 L- R: K p4 `" F: \7 S
case "onkeypress":, i! N6 t6 @* \% u* U0 c# J8 H
case "onkeydown":
1 q/ d* t/ n( j' |) |6 W" a case "onkeyup":3 x5 B. g( T" }
case "onload":
6 C6 w4 t! j9 V- K" {1 G q case "onlosecapture":3 U! P/ ]) `, q C
case "onpropertychange":
$ _8 Q% z& g" W- x& x- F, K: b case "onreadystatechange":/ j$ [. f1 I5 B( ^% k8 z$ o
case "onrowsdelete":
6 b' S" H+ g: x( F( w case "onrowenter":, J. k/ X; ^& E
case "onrowexit":$ D: x0 w+ g9 e8 d8 k6 L5 K2 o
case "onrowsinserted":9 V) E: M) F" h5 j) O& `, @! F
case "onstart":
$ a5 c$ G& C: _ case "onscroll":
. k$ m- {3 C! P5 v+ f V- h! ? case "onbeforeeditfocus":
$ |7 `4 x( F9 x- p; P# ?7 ?) t case "onactivate":
! b6 P, \0 _' I; a1 a9 [, G case "onbeforedeactivate":7 ^& b4 h, q$ `( r k8 Y% q
case "ondeactivate":
$ V' v6 k$ s& j; Z# b+ Q8 A7 f" I case "type":
1 C* B T D& Z3 L1 W3 N case "codebase":
! `2 n" b" N) N) Y9 O/ k ret.objAttrs[args] = args[i+1];8 |" n4 C6 `/ g: S7 b8 G: i
break;9 S3 m. f/ K) L' X
case "width":
0 S. Z: {3 P* E( y; Z case "height":
+ Q; d% @( ~) G case "align":
7 r& y! f2 r5 J/ F+ l9 a9 q case "vspace":
" o6 K' K1 o! Z5 ^) I+ N case "hspace":
1 u$ I& w' G- O5 v/ [5 T8 u; B0 ~7 G case "class":
( [4 a: J' @; h ]# m case "title":% G% r/ V* h8 l" E
case "accesskey":
Q7 S) x, ^0 {. U) ~ [ case "name": N4 L z k8 U$ ]. ]9 Y# v# R0 n
case "id":. b9 J+ ^3 A& @
case "tabindex":
, U, O' E% W$ c7 D' b4 x6 P ret.embedAttrs[args] = ret.objAttrs[args] = args[i+1]; w: v Q% d" K! c
break;* O3 ^ ?3 [1 x9 t
default:; [- e# {+ N/ F, @% O; {
ret.embedAttrs[args] = ret.params[args] = args[i+1];; n0 S k+ n8 F6 k5 j2 L# V: y% g$ C
}
% A; r* C" }9 `- ?9 D b$ r" l6 l }
6 P2 |2 t& l$ R( d: M8 y ret.objAttrs["classid"] = classid;4 Z$ x- N8 s6 N4 A$ k' \5 j: m
if (mimeType) ret.embedAttrs["type"] = mimeType;( f* _- P% f5 G- N6 T ~, K
return ret;4 [( P7 V) }3 K9 O7 q7 G+ E& O2 Z
}
# t& w: ^' C" D: }7 K' @8 U' |/ Q/ \% l9 \' A) [2 T
2、保存为:AC_RunActiveContent.js
8 C+ l* o c' O0 p! u T9 O: m
% Q/ q: u4 P$ q3、在所需的页面中添加;
. ?% ]1 V1 m3 J" Q
) @. l9 z! u$ ^9 S1 {<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>8 G- [9 n, L5 A- {* e
]! @- Z: G: y9 z( O
4、在插入FLASH的位置添加:
+ x3 P' q/ l) b2 f% E' s. O* N; V$ Q9 f& 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','1002','height','600','src','index','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','index' ); //end AC code</script>" i9 l7 H7 c& h3 n. e$ c; Z5 x
<noscript>
$ j' m. X9 e' K+ o' V3 I<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">! A5 Y' @# e2 F- J# Z/ r
<param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/index.swf">8 c' v* p- x2 I3 n
<param name="quality" value="high"> S& G; l$ S' `% x6 h6 r
<param name="wmode" value="transparent">
; [4 S9 V. l6 u5 T8 o$ U( h<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>0 R( C! ~% ^+ l4 R$ i9 A5 g# g9 P
</object>7 x) o$ P1 O: o# J% ?; _
</noscript>* Q/ G* d# @( ]7 F$ c+ A0 A& x% ?2 P8 j2 p
$ ^; P8 \) I6 L) B5、页面中的完整代码:
& u" u" r$ u9 n, k8 L. b7 V7 i5 F1 h. r# ?" P
<html>8 G. \; z6 J9 k. E* @
<head>
q/ Q- l; n! D3 X4 h% b1 D<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />' K4 O2 m- ?0 {0 I7 W: w# y
<title>IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法</title>5 N; n" x9 G K
<!--加载AC_RunActiveContent.js,此为DW自动生成的文件,无需修改,更改文件目录的时候记得修改这里的路径-->8 c" l* M$ a( H( B, Z. U) P$ i
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>! `5 d" k/ H( t4 l) {4 Z8 \5 z
<style type="text/css">
; E2 p) _/ ~. a4 V y; u& ?" v# e/ e<!--
$ E& R8 Z. t8 v2 ]6 j- k; S2 F# Y2 lbody {! ^9 e, X/ k: r& e; K% z
background-color: #CCCCCC;
; v' \- ^& `% [3 U+ Y} _( d% ~$ Y0 Q, x; M3 ] J
-->
* u5 u, n+ A8 C</style></head>
e: U8 a0 I! P# E$ ~- |<body>7 |* ~. _7 o, a& _& T; O
3 f$ A% U% q# Y6 v1 ~( ?- X; ^1 A
<!--下面这段JS修改的时候要注意,一共要修改四个地方:4 C8 y" Z0 l5 Q* P2 O+ [3 I i
300 是宽度;
5 o, `* @: w# h2 j: X* R; c9 w200 是高度;) A* |( n- o. U/ H9 m% j" L! n
images/killIEBorder 是路径和文件名,修改时注意,共有两处,还要特别注意,文件名后面不要加“.swf”,此后缀已经写在AC_RunActiveContent.js中-->) t) u! ~+ V+ ^/ x2 [( v7 l
<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>8 N7 S0 \3 i# e$ H0 B- V. e
<!--遇到浏览器禁用javascript时将调用下面这段<noscript></noscript>内的代码,就是Dreamweaver升级到8.0.2之前我们插入flash时的那段代码。<param> 标签针对IE起作用,<embed> 标签针对Firefox和Netscape起作用。-->
# M i F: ~" v: P0 |7 k: x<noscript>
0 l: z- _* V9 j7 `. F8 x<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">* v/ c4 z6 Y6 t: P/ n0 p
<param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/images/killIEBorder.swf">
6 @6 { V! Y$ J# n8 I0 b <param name="quality" value="high">2 y0 l8 B$ q1 z
<param name="wmode" value="transparent">
- H* K8 p2 a8 g- Z <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>& c1 T2 f3 B+ S4 ]
</object>
# ~& f- S9 x$ I</noscript> |
|