在做zblog模板的时候常常要用到幻灯片插件,但是文章页却调用不了。
今天给大家分享一个js调用幻灯片的方法。
首先新建一个js文件,代码如下:
var interval_time=8;
var focus_width=710
var focus_height=210
var text_height=0
var text_mtop = 2;
var text_lm = 10;
var textmargin = text_mtop+"|"+text_lm;
var textcolor = "#2E5DB5|0xFF0000";
var text_align= 'left';
var swf_height = focus_height+text_height+text_mtop;
var text_size = 14;
var borderStyle="1|0x000000|0";
var pics='img/gg1.jpg|img/gg2.jpg|img/gg3.jpg|img/gg4.jpg';
var links='/product.html|/product.html|/product.html|/product.html';
var texts='1|2|3|4|5';
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="img/hot_new.swf"> <param name="quality" value="high"><param name="wmode" value="transparent">');
document.write('<param name="menu" value="false">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'&textmargin='+textmargin+'&textcolor='+textcolor+'&borderstyle='+borderStyle+'&text_align='+text_align+'&interval_time='+interval_time+'&textsize='+text_size+'">');
document.write('<embed src="img/hot_new.swf" wmode="transparent" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'&textmargin='+textmargin+'&textcolor='+textcolor+'&borderstyle='+borderStyle+'&text_align='+text_align+'&interval_time='+interval_time+'&textsize='+text_size+'" menu="false" bgcolor="#ffffff" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>');
然后在网页中调用这个js文件即可
<script src="img/banner.js"></script>
图片和js代码要传好就会显示如下的幻灯片。
相关阅读:
网友点评