flash幻燈片需要先激活ActiveX控件才能使用的又一個辦法
更新時間:2007年11月14日 23:16:01 作者:
微軟由于種種原因,在 sp2 后限制了 IE 的 ActiveX 的使用模式,就是在頁面中的 ActiveX 有一個虛框,需要用戶點擊一次才能正常交互。Flash是作為一個 ActiveX 嵌入到網頁中的,所以它也會受牽連,只有通過 JS 嵌入 Flash 才能解決這個問題。沒有 Flash 版本檢測,如果版本瀏覽器的flash插件版本不夠,或者不能正常顯示你的 swf 文件,或者會彈出一個 ActiveX 的確認安裝的框——這個框對很多用戶來說是很恐怖的,網上找了半天,沒有一個關于幻燈片廣告代碼,沒辦法,自己研究了,經過測試通過。
首先在<head>區(qū)域,插入引用:
<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,在幻燈片區(qū)域調用:<!--#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播放文件
首先在<head>區(qū)域,插入引用:
<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,在幻燈片區(qū)域調用:<!--#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播放文件
相關文章
HTML5實戰(zhàn)與剖析之觸摸事件(touchstart、touchmove和touchend)
本文主要介紹HTML5實戰(zhàn)與剖析之觸摸事件,介紹的比較詳細,需要的朋友可以參考下。2016-06-06兼容多瀏覽器實現(xiàn)半透明(Opera ie firefox)
兼容多瀏覽器實現(xiàn)半透明(Opera ie firefox)...2006-12-12激發(fā)你的靈感:50個優(yōu)秀的Favicons
激發(fā)你的靈感:50個優(yōu)秀的Favicons...2007-02-02