jb51站长推荐的用js实现的多浏览器支持的图片轮换展示效果在ie,firefox和测试一切正常,建议以后大家都要用这样的兼容性比较好的代码
body {margin:0 auto; padding:0; text-align:center }
.box400 {margin:0 auto;padding:0;width:400px}
#f_menu {
margin: 0px auto; overflow: hidden; width: 400px; height: 20px
}
#f_menu a {
display: block; background: #393939; float: left; overflow: hidden; color: #fff; line-height: 20px; margin-right: 1px; border-bottom: #fff 1px solid; height: 20px; text-align: center
}
#f_menu a:hover {
background: #ff8500
}
#f_menu a.on {
background: #ff8500
}
#f_div {
margin: 0px auto; overflow: hidden; width: 400px; height: 200px
}
#f_addiv {
overflow: hidden; width: 100%; height: 25px
}
#f_imgdiv {
overflow: hidden; width: 100%; height: 200px
}
#f_img {
border-right: 0px; border-top: 0px; filter: progid:dximagetransform.microsoft.fade(overlap=1.00); border-left: 0px; border-bottom: 0px
}
#f_infodiv {
width: 100%; position: relative; top: -14px
}
#f_buttondiv {
overflow: hidden; width: 100%; margin-right: 1px; height: 14px; text-align: left
}
#f_line {
background: #fff; filter: progid:dximagetransform.microsoft.alpha(startx=0, starty=0, finishx=50, finishy=100,style=1,opacity=0,finishopacity=100); margin-left: 270px; overflow: hidden; width: 130px; height: 1px
}
#f_buttondiv div {
background: #fff; float: right; width: 1px; height: 14px
}
#f_buttondiv .bg {
background: #fff; filter: alpha(opacity=40); float: right; width: 14px; height: 14px
}
#f_buttondiv a {
display: block; font-size: 10px; float: right; overflow: hidden; width: 14px; color: #fff; padding-top: 0px; font-family: arial, helvetica, sans-serif; position: absolute; height: 14px; text-align: center; text-decoration: none
}
#f_buttondiv a:link {
color: #000
}
#f_buttondiv a:visited {
color: #000
}
#f_buttondiv a:active {
color: #000
}
#f_buttondiv a:hover {
background: #ff840c; color: #fff
}
#f_buttondiv a.on:link {
background: #ff840c; color: #fff
}
#f_buttondiv a.on:visited {
background: #ff840c; color: #fff
}
#f_buttondiv a.on:active {
background: #ff840c; color: #fff
}
#f_buttondiv a.on:hover {
background: #ff840c; color: #fff
}
#f_buttondiv a.on:hover {
background: #ff6600
}
#f_text {
overflow: hidden; line-height: 26px; height: 26px; text-align: center
}
#f_text a:link {
color: #000; text-decoration: none
}
#f_text a:visited {
color: #000; text-decoration: none
}
#f_text a:active {
color: #000; text-decoration: none
}
#f_text a:hover {
color: #ff6600; text-decoration: none
}
<!--
function p$(string){
document.write(string);
}
function $(id){
return document.getelementbyid(id);
}
function change_menu(id,content_id,num,total_ztc_menu,menu_on,menu_off){
for (var i=1;i
<!--
//可修改区域
var imgwidth=400;
var imgheight=200;
var _timeout_=5000;
var show_text = true; //是否显示焦点文字
var timeout=_timeout_;
var timeout2=_timeout_/2;//onmouseout img后需要切换的时间
var now=0; //第一张图
var target="_blank"; //打开方式
var button_on ='on'; //当前焦点对应按钮的样式名
var button_off ='';//非当前焦点对应按钮的样式名
//不可修改区域
var imgurl = new array();
var imgtext = new array();
var imglink = new array();
var imgalt= new array();
var menulist = new array();//菜单menu
var ver=2; //兼容浏览器版本 默认2 为非ie
var firsttime=true;
var n =-1;
//菜单menu
menulist[++n]='内外兼修';
imgurl[n]='http://www.pcauto.com.cn/newcar/abroad/porsche/images/picpath/070308techartl.jpg';
imgtext[n]='内外兼修 techart改装600匹卡宴turbo';
imglink[n]='http://www.pcauto.com.cn/newcar/abroad/porsche/0703/430540.html';
imgalt[n]='内外兼修 techart改装600匹卡宴turbo';
//菜单menu
menulist[++n]='新福克斯';
imgurl[n]='http://www.pcauto.com.cn/nation/brand/changanford/images/picpath/07kuanfukesi4002000309.jpg';
imgtext[n]='';
imglink[n]='http://www.pcauto.com.cn/nation/brand/changanford/0703/430704.html';
imgalt[n]='07款福特福克斯上市 售价12.98-16.58万';
//菜单menu
menulist[++n]='悍马姐妹';
imgurl[n]='http://www.pcauto.com.cn/community/carnbeauty/images/picpath/8_mthwoei4.jpg';
imgtext[n]='';
imglink[n]='http://piclib.pcauto.com.cn/piclib/x_index.jsp';
imgalt[n]='捍马车展的孪生姐妹 超酷';
//菜单menu
menulist[++n]='脱衣秀';
imgurl[n]='http://www.pcauto.com.cn/news/yjpl/medium/images/picpath/lishufu-a98sudfoa.jpg';
imgtext[n]='';
imglink[n]='http://www.pcauto.com.cn/news/yjpl/medium/0703/430599.html';
imgalt[n]='吉利李书福委员脱衣秀国货 呼吁支持国货';
//菜单menu
menulist[++n]='养路费';
imgurl[n]='http://www.pcauto.com.cn/news/hyxw/images/picpath/yanglufei-400200-809asudfol.jpg';
imgtext[n]='';
imglink[n]='http://www.pcauto.com.cn/news/hyxw/0703/430739.html';
imgalt[n]='人大代表建议全国统一养路费征收法规';
//菜单menu
menulist[++n]='大发';
imgurl[n]='http://www.pcauto.com.cn/nation/brand/other/images/picpath/8e026ba4d70309400200.jpg';
imgtext[n]='';
imglink[n]='http://www.pcauto.com.cn/nation/brand/other/0703/430723.html';
imgalt[n]='大发国产小车年中上市 1.3和1.5两种排量';
var count=0;
for (var i=0;i");
p$("");
p$("");
function change(){
if (ver==1){
with($('f_img').filters[0]){
transition=1;
apply();
play();
}
}
if (firsttime){ firsttime=false;timeout=_timeout_/1000;}
else{
$('f_img').src=imgurl[now];
$('f_img').alt=imgalt[now];
$('f_imglink').href=imglink[now];
if (show_text) $('f_text').innerhtml=imgtext[now];
for (var i=0;i=imgurl.length-1)?0:now+1;
timeout=_timeout_;
}
thetimer=settimeout("change()", timeout);
}
function b_change(num){
window.clearinterval(thetimer);
now=num;
firsttime=false;
change();
}
//draw 渐变line (即css:f_line)
function draw_line(){
var div = document.createelement("div");
div.id = 'f_line';
$('f_infodiv').insertbefore(div,$('f_infodiv').childnodes.item(0));
}
//表现层 start
//menu
for(var i=0;i=0;i--){
var div_bg = document.createelement("div");
div_bg.id = 'div_bg'+i;
div_bg.classname='bg';
$('f_buttondiv').appendchild(div_bg);
var a = document.createelement("a");
a.id = 'b'+i;
a.classname = (i==now+1)?"button_on":"button_off";
a.title=imgalt[i];
a.innerhtml=i+1;
a.href='javascript:b_change('+i+')';
$('div_bg'+i).appendchild(a);
var div= document.createelement("div");
$('f_buttondiv').appendchild(div);
}
if (show_text) $('f_text').innerhtml = imgtext[now];
//表现层 end
$('f_img').onmouseover=function(){window.clearinterval(thetimer);}
$('f_img').onmouseout=function(){thetimer=settimeout("change()", timeout2);}
try{ //滤镜版本
new activexobject("dximagetransform.microsoft.fade");
$('f_img').filters[0].play();
ver=1;
draw_line();
}
catch (e){ver=2;}
var thetimer = settimeout("change()", _timeout_/1000);
//-->
|
[ctrl+a 全选 注:如需引入外部js需刷新才能执行]