|
楼主 |
发表于 2008-1-8 22:28:00
|
显示全部楼层
回复:对比国内门户网站对Flash激活限制的处理
IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法。* N2 {4 s* ?" _' o' r
% R: B+ I5 \6 ^' r% G+ u当鼠标移到网页中的FLASH上时,会出现一个外边框。并有“单击以激活此控件”的提示。解决方法:
5 F% f+ w6 M3 \. U! D0 f$ d, f5 G
& N/ I( x* j8 z1 }+ x" ]; i1、新建JS文件:
1 N' O+ j4 g' i
8 n6 H4 R F* {# D- Q/ V* S//v1.0# J& @& e# b/ w4 S- Q
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
" B! U* y+ C) l2 z' a$ N; Ofunction AC_AddExtension(src, ext)/ j; E- Z, y$ a l7 Z
{4 v& k" y- a7 f8 _, k
if (src.indexOf('?') != -1)( O" I3 M, U! \- \$ {/ Q$ T6 I5 ?$ s
return src.replace(/\?/, ext+'?'); & w0 D* T4 X7 x& V" L, f3 i
else8 t) \' k. J' X, [) o. k
return src + ext;4 \6 r: x2 l/ M s( H
}
4 G( I: i- ]% L% P L. d
4 H2 F6 t; i; ?. Z, gfunction AC_Generateobj(objAttrs, params, embedAttrs) % _0 X/ `4 d) D' b7 L
{ 5 |5 H* r7 \7 A, G# ]4 e, c3 `. h
var str = '<object ';" \9 Q/ y! S: h# A8 i3 T5 f' ~
for (var i in objAttrs)
" T/ u& g/ ~5 `% P str += i + '="' + objAttrs + '" ';( E, T1 B$ X$ j" w7 W' x' P- G
str += '>';
: B* T' ?: m0 W! n8 [ for (var i in params)' b4 a& X1 [8 k& E' y0 [& x0 F
str += '<param name="' + i + '" value="' + params + '" /> ';
o" K- D. e1 o6 | str += '<embed ';
d( ~ m7 g+ ]! V# f9 C! E7 p2 H/ p for (var i in embedAttrs)- G# L( } T. [7 K
str += i + '="' + embedAttrs + '" ';: x S8 V1 C& x6 m% [
str += ' ></embed></object>';
$ Z2 U7 N Y6 I- I
. l/ @/ I( B- o2 B$ J f- o document.write(str);' \" M1 Z( {, i6 M: Q3 o6 `1 D3 }
}
' P( M! I5 T$ M6 E" Q/ J0 F/ `- i7 D; k: N" \* u- o& A
function AC_FL_RunContent(){
, m. i" y6 d8 k9 r+ T+ W2 k var ret =
* i6 a$ M+ ~: z1 } AC_GetArgs
# _4 }" a4 _) @7 _6 x% W ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
- z% K. n- t5 k3 M! ] , "application/x-shockwave-flash"/ ]3 J7 S8 I1 ]) i/ x" p# A
);
, t( `, r/ U' ~3 O1 L AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);# R6 L; P- J' r' ?9 x# Y
}
8 `$ E% H+ B2 w4 n5 J
- A7 h5 p3 n/ Y: n$ |function AC_SW_RunContent(){
+ S% A S% Q* r( z' e9 P var ret = ( G8 h8 ^5 B1 u) e6 i
AC_GetArgs
3 e: l1 u9 H- _ ( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
- f: H7 X I! y: J5 b , null) d& _/ B4 A- [6 j; O3 f
);
- A2 e( l+ Z& y( | AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);: g2 \# {0 d; p/ T1 B0 f% r" a
}
; a# i" t) s" X5 d! }4 ^* j5 c! ~8 B+ A! t: E, ~
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
' s0 Y: @* u: E$ a3 r$ a. @ var ret = new Object();
9 s" _6 _) o( C1 k8 D) H ret.embedAttrs = new Object();1 s4 v2 u# [9 n, q
ret.params = new Object();: S4 ^7 E7 b- _ M/ v4 T* M" @
ret.objAttrs = new Object();
8 a2 T+ j$ J/ [0 O, _0 n3 h for (var i=0; i < args.length; i=i+2){
) L3 c& \; K- b2 l1 o+ i var currArg = args.toLowerCase();
! c+ B. {/ L2 N: X$ S3 k; s
9 s- @3 ]' o) U) K$ W) J B$ [ switch (currArg){
6 y( n& W$ Q) x case "classid":% a( }2 j2 y! C& l
break;5 q$ f1 O& o3 ?9 B8 l
case "pluginspage":6 _/ c$ G% {4 R, D6 P6 `( [; z
ret.embedAttrs[args] = args[i+1];
5 F0 E1 E, d- y# m" V break;/ j! h) }9 d/ y: }( z" k
case "src":& u8 U; A" E; u2 _$ e2 o7 z i- {5 o
case "movie":
. ~ G6 l+ I3 a& \ args[i+1] = AC_AddExtension(args[i+1], ext);
! J3 l& F# @# n. O h ret.embedAttrs["src"] = args[i+1];; F6 f- j' g' W# U
ret.params[srcParamName] = args[i+1];
7 W/ W, j9 ]2 B9 a" R break;
- E8 h+ m( m- O4 J9 V9 f4 H8 v case "onafterupdate":
2 v+ h' l# n0 I1 `& @% ]- l& K; L' F0 y2 U case "onbeforeupdate":' q2 |3 p; f8 T' q8 r& Z
case "onblur":6 @4 A; b5 |: v( q/ m: T o1 @2 R |, U
case "oncellchange":9 i. O/ Z' u2 ]% g! \0 j: t2 A9 M
case "onclick":
7 t& ?) `. d. I+ @; } case "ondblClick":1 d e6 |. z7 C& S0 U% W
case "ondrag": m% H5 t" g, n3 A! w- ^
case "ondragend":7 h( @, s8 f8 P9 F( e
case "ondragenter":
0 I) w ]% d9 U( G; M; A case "ondragleave":
" m: G+ g2 Z6 C- f# s, \ case "ondragover":" \. b2 l9 z4 I. G/ ~
case "ondrop":
7 m, X* e& ]$ r w5 s! _ V case "onfinish":& v' B1 T6 v; h. F( m" i" k9 B
case "onfocus":
" T7 \" w# C) y case "onhelp":
+ g5 e" S9 d1 [; A case "onmousedown":
7 U+ J" z2 d$ K8 ?/ u case "onmouseup":
/ q& ~8 ^8 b* \4 Y5 D7 B3 }( {/ a: \ case "onmouseover":
7 `/ I' C3 x0 T8 g# n case "onmousemove":4 E" x! u5 t; v
case "onmouseout":
$ l$ X* [9 d1 g0 G case "onkeypress":
5 F& h3 |8 J2 B/ _0 q7 E$ Z- S case "onkeydown":
. d$ @* F. [2 i case "onkeyup":2 n; ?& h0 |. k) O0 y! h; u! r/ J
case "onload":" e N$ X# v+ L3 w7 a. S; D
case "onlosecapture":
" `5 s) G# S: u. d! w; N case "onpropertychange":2 [1 E* M8 v; u, b" D
case "onreadystatechange":
1 y5 P( `& G4 H0 ?: N# o3 ~ case "onrowsdelete":6 |% _2 c5 ^5 Q, i) B: h
case "onrowenter":
& v4 q+ e, l5 Y9 }( B5 | case "onrowexit":
3 B+ z& g' M0 s) h; H case "onrowsinserted":/ f: v5 r: s4 c1 s3 K/ r
case "onstart":+ y$ g- P0 y) h# I f/ a
case "onscroll":
0 @/ w$ O# w9 p" V" ~: J% B case "onbeforeeditfocus":5 i0 w, ]; s7 X; s y
case "onactivate":/ o; \3 {) P; S& J- |- z& _
case "onbeforedeactivate":
. m( _$ m. I3 `% f8 n0 h case "ondeactivate":
X7 |1 N L9 ` case "type":
: x5 O! ]5 L, l# l) Y case "codebase":4 q7 g1 s4 f4 U+ f/ `8 ~/ G
ret.objAttrs[args] = args[i+1];
1 _3 V8 C. y6 t* O% N break;, J! b5 z' Z! T& |- v, ]) k
case "width":
5 I% Z2 ^6 G/ c# }- t! o% k case "height":
+ Y- n) d: q( x' P; C+ B1 v7 i! l case "align":! A# u) j* k- W$ C' [
case "vspace":
4 v* Y/ I- A2 \9 L3 W0 [) o" z case "hspace":; Z( k! e+ t8 l. c$ R7 I: @0 P
case "class":. n; G. Y& h- O" v5 t1 L2 ~
case "title":1 \( Z9 [# P' o1 X& s% s' i$ W
case "accesskey":
. R% m) V3 x% d" m- C. ?2 r case "name":
7 _2 h( X6 S9 o+ z) z case "id":1 G$ P/ n5 m) B. d6 [
case "tabindex":
% A/ P% L% [$ O" W ret.embedAttrs[args] = ret.objAttrs[args] = args[i+1];, D5 H! k; z1 b- M0 ^
break;
2 X9 B$ u( `: |; \ default:
! `: [1 f* @4 B' u+ ~7 x- ~ ret.embedAttrs[args] = ret.params[args] = args[i+1];
, i% M5 I4 G- U$ [! q- i }
- {5 R# q* h9 o' S3 N _ }5 u7 q G9 V5 T; z# Z
ret.objAttrs["classid"] = classid;
0 x! n1 ^' Q9 e) F! {: T if (mimeType) ret.embedAttrs["type"] = mimeType;
4 ]* z! e1 P/ \- K( a+ n+ f. J return ret;3 _2 D! i- W& ?0 @- X a* Y
}4 ?9 s$ B8 F' F4 V2 q$ x+ n3 f: {' d
2 t; p! v i2 q: |% ?/ j8 i* M
2、保存为:AC_RunActiveContent.js
$ l( y2 Q) h( q" k& s S3 L
2 j9 S. Z& g9 j4 J3、在所需的页面中添加;
8 H8 O- |8 c* s) \" K4 c( M: _. F# d, o) l7 M% P* A: A% v
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>" O: d; `! Z: F$ @, l' K$ L
% r/ [" T, g6 V* G* P4、在插入FLASH的位置添加:
2 A% r6 ^0 C, ^
3 Q# g% b9 H- w6 y; a1 _9 `<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>) D4 Z ^5 u& M8 ]. C
<noscript>
; j5 @% R c2 p% ~* i. p1 W: l6 h5 ~<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">
1 X0 u' [( k$ A- O5 y<param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/index.swf">$ G/ o% Y' N% n! W" L
<param name="quality" value="high">8 Y) V* K) d2 g
<param name="wmode" value="transparent">+ n& {$ U2 b( k1 J& z( m
<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>3 c2 W. `, E% V; N- B! ~' A
</object>
) F% w0 P- `" O) |) P</noscript>0 @; o0 r. P; q" a" t+ P
6 |/ e- m4 L; m5、页面中的完整代码:
4 H' |: N6 B- }. p5 B$ q6 `* ]% ]# W+ o2 v/ {$ k& [
<html># u* K' C: Q7 G, a! {
<head>+ f$ d3 s* X- W) q- a( v2 m8 I
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- o5 y7 p$ |; }5 X<title>IE中的Flash出现激活框“单击以激活并使用此控件”的解决方法</title>/ B0 V5 t# j" Q( K. H7 T
<!--加载AC_RunActiveContent.js,此为DW自动生成的文件,无需修改,更改文件目录的时候记得修改这里的路径-->3 L; B. D: y; _0 [$ V- U
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
$ w3 j8 [2 i' q# K<style type="text/css">
5 W7 O1 }$ w. s* u0 O<!--
5 O( E1 ~4 T# h& h8 E/ [body {
5 p. w! Z% b4 J background-color: #CCCCCC; |: M% y7 u/ ~
}8 E+ v7 V s) ~ x( z3 V
-->
4 e8 q' k4 k. i+ \5 H& U' |</style></head>* ?. F6 F4 W- Y0 L+ c1 P
<body>
% {" i: _9 {+ A0 F, P* j i' d% Q) k. `. O& F! t( A
<!--下面这段JS修改的时候要注意,一共要修改四个地方:5 i6 O( G' S. M( K: S2 r6 p
300 是宽度;# I: J' k! Y3 }$ |* H% Q5 t* u
200 是高度; F: |1 B0 y# m# j* L
images/killIEBorder 是路径和文件名,修改时注意,共有两处,还要特别注意,文件名后面不要加“.swf”,此后缀已经写在AC_RunActiveContent.js中-->1 A& ?- p3 a/ U% k( q3 {$ e
<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>
( o7 g/ W f3 S+ x) C l! h( \<!--遇到浏览器禁用javascript时将调用下面这段<noscript></noscript>内的代码,就是Dreamweaver升级到8.0.2之前我们插入flash时的那段代码。<param> 标签针对IE起作用,<embed> 标签针对Firefox和Netscape起作用。-->
2 v C0 Y. P( g1 Y0 U ? Y<noscript>5 z i4 a' d9 R' `
<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">) N6 C8 D& X4 W5 ?) ^/ |, b
<param name="movie" value="http://www.webjx.com/htmldata/2007-04-22/images/killIEBorder.swf">$ w# |0 u9 U% N% {& O
<param name="quality" value="high">& t/ P) r: {* R& W4 j1 E
<param name="wmode" value="transparent">5 S/ T9 Q4 r% J. a( N! D0 \
<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>
/ R" K: f1 S" I; @' w</object>
. Z+ P5 @* T$ |</noscript> |
|