flash幻灯片需要先激活ActiveX控件才能使用的又一个办法

  微软由于种种原因,在 sp2 后限制了 IE 的 ActiveX 的使用模式,就是在页面中的 ActiveX 有一个虚框,需要用户点击一次才能正常交互。Flash是作为一个 ActiveX 嵌入到网页中的,所以它也会受牵连,只有通过 JS 嵌入 Flash 才能解决这个问题。没有 Flash 版本检测,如果版本浏览器的flash插件版本不够,或者不能正常显示你的 swf 文件,或者会弹出一个 ActiveX 的确认安装的框——这个框对很多用户来说是很恐怖的,网上找了半天,没有一个关于幻灯片广告代码,没办法,自己研究了,经过测试通过。

  首先在<head>区域,插入引用:

  <script. src="ad/global.js" type="text/javascript"></script>

  global.js 代码如下:

  

复制代码 代码如下:

  function my_getbyid(id)

  {

  itm = null;

  if (document.getElementById)

  {

  itm = document.getElementById(id);

  }

  else if (document.all)

  {

  itm = document.all[id];

  }

  else if (document.layers)

  {

  itm = document.layers[id];

  }

  return itm;

  }

  function sunad(element,url,width,height,images,links,texts)

  {

  if (!my_getbyid(element)) return;

  var str = '';

  str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,9,0" width="'+ width +'" height="'+ height +'">';

  str += '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+url+'"><param name="quality" value="high"><param name="bgcolor" value="#ffffff">';

  str += '<param name="menu" value="false"><param name=wmode value="opaque">';

  str += '<param name="FlashVars" value="pics='+images+'&links='+links+'&texts='+texts+'&borderwidth='+width+'&borderheight='+height+'&textheight=0">';

  str += '<embed src="'+url+'" wmode="opaque" FlashVars="pics='+images+'&links='+links+'&texts='+texts+'&borderwidth='+width+'&borderheight='+height+'&textheight=0" menu="false" bgcolor="#ffffff" quality="high" width="'+ width +'" height="'+ height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

  str += '</object>';

  my_getbyid(element).innerHTML = str;

  }

在需要放置幻灯片的地方,用下面的代码覆盖,也可以把下面的代码单独写成一个文件调用,

  如文件名为ad.asp,在幻灯片区域调用:<!--#include file="ad.asp" -->

  

复制代码 代码如下:

  <div id="story_flash"> </div>

  <a target=_self href="javascript.:goUrl()">

  <script. type="text/javascript">

  url_0="http://www.abc.com";

  img_0="http://www.abc.com/01.jpg";

  url_1="http://www.abc.com";

  img_1="http://www.abc.com/02.jpg";

  url_2="http://www.abc.com";

  img_2="http://www.abc.com/03.jpg";

  url_3="http://www.abc.com";

  img_3="http://www.abc.com/04.jpg";

  url_4="http://www.abc.com";

  img_4="http://www.abc.com/05.jpg";

  var focus_width=250

  var focus_height=250

  var text_height=0

  var swf_height = focus_height+text_height

  var pics =img_0+"|"+img_1+"|"+img_2+"|"+img_3+"|"+img_4

  var links=url_0+"|"+url_1+"|"+url_2+"|"+url_3+"|"+url_4

  var texts = '';

  var focus = 'http://www.abc.com/ad/focus.swf';

  sunad('story_flash',focus, focus_width,swf_height,pics,links,texts)

  </script>

  </a>

  上面代码中:var focus = 'http://www.abc.com/ad/focus.swf';

  这句的focus.swf是flash播放文件