|
楼主 |
发表于 2008-1-8 22:28:00
|
显示全部楼层
回复:对比国内门户网站对Flash激活限制的处理
IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法。7 s' l( h! f" q& ]) o
& R9 a* V+ N& [6 p5 T5 Q
当鼠标移到网页中的FLASH上时,会出现一个外边框。并有“单击以激活此控件”的提示。解决方法:
' `# b) E% l+ z/ C
) |7 X8 ]4 F9 O: h1、新建JS文件:7 y; I. f" U# e6 B
/ ?+ E* J: D/ [, `5 v+ m N//v1.03 B0 N5 M+ ]1 s$ x* R; f
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
5 Y7 S. i+ A# m1 @9 I2 G# Pfunction AC_AddExtension(src, ext)( i& z6 x7 ~, v/ N2 e5 X
{0 L$ T% T2 L* |0 e8 U9 A- }; I. J
if (src.indexOf('?') != -1)
$ {. d# A: N0 S$ y8 R return src.replace(/\?/, ext+'?'); + r: M9 c( E4 z0 z- s, |2 ^, Z4 v
else
9 C! d5 ?' N2 Z% I, [; p/ m& d return src + ext;
+ p# m" H: P. H9 A5 v, f}
% s1 H4 H! N7 C. a+ d4 K+ M# V' j8 B. c; h, E
function AC_Generateobj(objAttrs, params, embedAttrs)
h* h2 V2 b. U3 u8 n; {{ * B# ~" A9 D P$ S( u4 b
var str = '<object ';# O( h0 O9 P# x( z* v- J+ `
for (var i in objAttrs)0 {( R y) j, R$ G! h
str += i + '="' + objAttrs + '" ';
$ Z, o& F0 O1 k4 l! t. _3 L0 r str += '>';
5 [# p0 h# P: R3 ]3 {8 w4 ^ for (var i in params)
X9 z4 W+ ]0 c3 l$ \3 s, ] str += '<param name="' + i + '" value="' + params + '" /> ';
; [ @0 S- M) p( G4 c str += '<embed ';
$ E+ _! O3 U! \+ M8 z) m for (var i in embedAttrs)
% X9 |; C3 v3 h& [. f str += i + '="' + embedAttrs + '" ';
8 N, S4 v- ^# z) H3 K str += ' ></embed></object>';! z( ~+ Y, j) a$ Y% u/ |
- Z; Q( g; G6 ~9 r4 r9 B document.write(str);
* t' r9 o+ q" B& T}/ Y6 m) F& F$ [" W
+ ` m7 x; j; [: [; kfunction AC_FL_RunContent(){
1 L7 ]0 V4 _0 L& z" j var ret =
4 Z7 m r8 q \3 u0 Q2 x1 ~# L AC_GetArgs
' L+ T4 \" x: Z% p( P ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
S/ w/ j- |; E$ A! n , "application/x-shockwave-flash"
+ P0 i8 ?- I0 R6 R ^$ a8 M2 q0 W. | );7 |- Q: g6 u$ c; }2 D
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
9 A& v. X8 O2 {' x6 u& W6 H$ y `}
- b- J9 b. Y' u9 e3 a5 W2 w6 F$ r }
function AC_SW_RunContent(){3 t. Z7 g- n P! V6 @% U. e q
var ret = 8 M# i5 X9 H. [- g
AC_GetArgs
( [5 S2 r/ f( C9 h ( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"7 g! w. G: i+ U, q* \3 U' v
, null# F$ w& i4 i: u' ~& e
); L, M6 z$ k3 T
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
8 @8 g" O* u, L' q}
& ~' k* j5 e' _- F1 e c B! f3 T1 F6 x4 @5 t6 ?
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
- k4 m6 v% p5 u! _4 u& ^$ O var ret = new Object();" s4 \5 f5 w, G2 J" N. V. l# {
ret.embedAttrs = new Object();
# f0 ^4 x: F! r* d2 @/ s ret.params = new Object();
7 h$ B& C3 d# w6 h) G ret.objAttrs = new Object();
/ I8 x- q' L& e for (var i=0; i < args.length; i=i+2){
3 v6 @7 a3 p! l# Z2 ]- y var currArg = args.toLowerCase(); ' d0 r0 H8 j6 i6 e3 d) c- Q& R% \
" s( H+ z/ ?7 O2 `
switch (currArg){
. t8 @& L3 B$ u$ [ case "classid":% z( U! R; B E, W! S5 |# d
break;" G8 p% L- v4 p% d$ ~
case "pluginspage":" J0 v, W* k. G1 y9 k
ret.embedAttrs[args] = args[i+1];
( \3 F! r' J& S Q- J break;7 b- x: J, }+ D3 ]# E
case "src":. i: U# \ }, B* d0 M
case "movie":
# N5 N7 } d8 k0 B args[i+1] = AC_AddExtension(args[i+1], ext);
: |7 k5 u$ m* H% f9 p ret.embedAttrs["src"] = args[i+1];
) J( V4 [0 H( y. Y7 _2 t* M ret.params[srcParamName] = args[i+1];3 d) d2 G v- [3 I
break;" f- n/ d5 W# h- c) I |
case "onafterupdate":% T$ M7 g' p* @4 X
case "onbeforeupdate":) [; h2 e; d% A) K
case "onblur":, {+ d, o! E3 [
case "oncellchange":. V! e' h8 O9 X! i
case "onclick":0 w/ ]. W. L" b/ J
case "ondblClick":: M6 I. H) e+ Y
case "ondrag":
6 K9 F) M0 `& J8 G7 \ case "ondragend":: V1 E9 _) Q$ G4 H4 l# d
case "ondragenter":& v5 ^! e; i; M. n+ U- e* h, e
case "ondragleave":# G$ k: Q0 t' V, n7 ]) ] _) t
case "ondragover":( F2 h2 k! \" Y" Q( Q/ s
case "ondrop":* _: |8 |) `3 A2 c$ W+ K
case "onfinish":+ b$ H3 t% t2 U7 |# ~
case "onfocus":
# p# b+ R# R( @, X) F. P case "onhelp": d3 ^( W" ^# B7 H. M
case "onmousedown":
! A% P( f. y# b( C9 l case "onmouseup":1 X: N0 o5 n* [- J! A, @
case "onmouseover":
. w, e# F, p8 q' n8 h0 T case "onmousemove": T- ?4 n# h! `/ ~9 L$ r0 a. t
case "onmouseout":. W3 y; b! m& F4 {' N5 e: P, C4 k* h
case "onkeypress":
2 U, j" }, I9 I9 K' h* h case "onkeydown":& q! Q% B8 u$ m; J; H7 j6 ^4 u: E
case "onkeyup":& u8 O/ j; [+ u4 T5 ]0 w; @
case "onload":( e! \! [9 @- E9 c2 Z N
case "onlosecapture":5 R# D' l& t2 o9 r( F/ `
case "onpropertychange":7 J- t8 O# n2 C( L' o3 ^
case "onreadystatechange":7 i8 C: q8 x0 A0 f
case "onrowsdelete":
2 b6 g. O; n, A' E+ m; Y9 t case "onrowenter":
/ s# d% y* R" Y( k/ K- F6 e# V- p case "onrowexit":& M3 ?" ^3 N' u3 z* K, Y. j1 N
case "onrowsinserted":2 p& A3 ?" y, }* b0 L% L
case "onstart":
. p$ Z \8 L4 M% t1 \! f case "onscroll":2 }, J! X( q2 f! o; p$ N& k- ~
case "onbeforeeditfocus":* K' O' h1 F* k( T, D( h
case "onactivate":8 d3 Q4 R4 s1 R) P
case "onbeforedeactivate":2 L% K u# ` x c( {
case "ondeactivate":, D _ f& }) j8 ~; D$ t, p
case "type":; T$ u) e; j; n' n$ C; R0 h, N
case "codebase":* g; B y: r* _& {4 }5 m
ret.objAttrs[args] = args[i+1];; |+ t1 F+ \ @# z% I F. ~
break;7 B" ]; x. s8 F- R
case "width":8 Z$ P% z1 Q3 a
case "height":
' ]% e4 w& e* \. r- p case "align":& L V" o$ H7 b$ l2 p- s" x" x
case "vspace": $ f, j8 P z5 H
case "hspace":
; ]0 `) c1 M2 u1 ^ case "class":* M% R) n6 i3 ^. [2 ?! s: L
case "title":7 l- d* f% `, f; |6 j- l Y
case "accesskey":9 ?! z0 n5 b [, E# j8 F( h
case "name":
# y9 t' {- _. N: Y) j$ f" x case "id":
5 F7 Y) b8 s. C: \' x case "tabindex":
) s( R) B# l' ^* {1 e ret.embedAttrs[args] = ret.objAttrs[args] = args[i+1];
9 U) Q6 |/ t+ P1 r3 p break;2 k+ k- k/ q8 D6 a2 B
default:) |" d+ s7 W7 P! q0 S' w
ret.embedAttrs[args] = ret.params[args] = args[i+1]; u. I* ^0 M+ D9 J$ v1 [
}' M w2 u6 Q5 X; B- K. R6 w8 I
}
+ X6 F7 b& }; u% }& F% A9 c ret.objAttrs["classid"] = classid;: b2 k% x4 l" }# G0 Z. V/ C7 ~: ~. P
if (mimeType) ret.embedAttrs["type"] = mimeType;' H! r1 f" y. \: v
return ret;/ k: c3 s9 J9 J# e( w
}
% B: b8 @- _+ U% \6 d1 H8 g* w2 Y$ j; I( `4 _- j; _7 ~4 I
2、保存为:AC_RunActiveContent.js5 j2 i! M( j& H7 B, \/ w. c
, g$ {! G' r9 o; i2 }8 e$ x8 H8 z5 y3、在所需的页面中添加;
* O$ z0 Q+ _* T A2 s4 u5 c v
/ A, a, O5 L8 ?: f8 J<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>9 S$ b, l/ X- r% h
2 w% F+ c5 o$ L G! s4、在插入FLASH的位置添加:! d: W0 i/ P7 Z& D# T
9 Z' c# U- b3 M% T \/ M/ b<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>
, F. ^# t0 v. x! C<noscript>
8 |+ A$ y- r3 K9 S+ ]) W<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">% G- @% M' B; f( q: b$ _
<param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/index.swf">: X( p o& t/ t
<param name="quality" value="high">
0 |0 O5 q% e6 b5 k<param name="wmode" value="transparent">
- P: W. z& d/ T O5 }5 t5 D. ~<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>
" _ {+ Z& x! d7 ?! o1 w</object>3 a ^, k2 z7 p; T0 z+ m1 S
</noscript>4 v7 }- ?2 I, q. ^% t6 {7 ~7 Q
$ O& `- q: S+ R- a
5、页面中的完整代码:
) Z; M! I* S% l1 v5 r2 l, l# k% L1 C9 [& j! a% v/ V
<html>) I! d% M' [* C9 W2 w t( }
<head># C; |; n" z" o" N
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
, p/ u7 P' _4 F* j0 \<title>IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法</title>
6 S5 B5 ~, a0 H<!--加载AC_RunActiveContent.js,此为DW自动生成的文件,无需修改,更改文件目录的时候记得修改这里的路径-->
# M% ]; i5 {' y: e' \<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>& a& `( e' A/ j/ C
<style type="text/css">6 v9 g; j+ s; D1 \ k
<!--
0 d. \$ p7 I/ F! M: M S/ [! ~body {
( {; O0 E6 u4 F2 [) \ background-color: #CCCCCC;
. w3 G. H) E, r( Z, s2 }8 j}9 }9 k0 R! r* B) ~0 S+ l
-->
" B: O5 ]) B/ u4 n</style></head>$ _0 E/ i4 O% O8 B" J5 ~ L
<body> W. r2 u z8 {( @$ w
4 k% x. M+ h; k' R! C# U! w
<!--下面这段JS修改的时候要注意,一共要修改四个地方:5 W2 m; n( x' V! C- c) f
300 是宽度;
2 A* w v4 C7 B200 是高度;% b- @! O& w7 V V2 q3 J
images/killIEBorder 是路径和文件名,修改时注意,共有两处,还要特别注意,文件名后面不要加“.swf”,此后缀已经写在AC_RunActiveContent.js中-->6 n' M" k) w# n7 D
<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>; Z% g! w1 e7 l+ C0 f
<!--遇到浏览器禁用javascript时将调用下面这段<noscript></noscript>内的代码,就是Dreamweaver升级到8.0.2之前我们插入flash时的那段代码。<param> 标签针对IE起作用,<embed> 标签针对Firefox和Netscape起作用。-->+ R# _/ j" h4 I7 t
<noscript>
9 }1 f7 y% N" d<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">
- |" D% M9 B4 y: R1 o <param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/images/killIEBorder.swf">
- L) i! p" N* X5 D0 [4 Y, L <param name="quality" value="high">8 N) a. `8 P8 t+ W
<param name="wmode" value="transparent">
7 s; u9 v+ t8 z0 A5 m7 u* u4 \0 N <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>
8 p$ [ L0 W& A</object>
+ d1 t& {6 A* [* ]- v) b; K5 U</noscript> |
|