网上找的一段代码,发现不能单独定义某个链接是否在新窗口中打开,自己琢磨了半天给加上了,另外添加了一些文字说明。希望对你有所帮助,转载请注明本站地址。
<SCRIPT language="javascript" type="text/javascript">
//定义的图片地址
img1=new Image ();img1.src=' other/img/index/9.jpg';
img2=new Image ();img2.src=' other/img/index/8.jpg';
img3=new Image ();img3.src=' other/img/index/7.jpg';
img4=new Image ();img4.src=' other/img/index/1.jpg';
img5=new Image ();img5.src=' other/img/index/6.jpg';
img6=new Image ();img6.src=' other/img/index/3.jpg';
//定义的图片链接地址
url1=new Image ();url1.src=' #';
url2=new Image ();url2.src=' #';
url3=new Image ();url3.src=' #';
url4=new Image ();url4.src=' #';
url5=new Image ();url5.src=' #';
url6=new Image ();url6.src=' #';
//定义的图片名称
bti1=new Image ();bti1.name='WWW.VDAZHANG.COM';
bti2=new Image ();bti2.name='WWW.YPENG.CN / WWW.ZHANGYUANPENG.COM';
bti3=new Image ();bti3.name='E-MAIL: MAIL@VDAZHANG.COM';
bti4=new Image ();bti4.name='E-MAIL: MAIL@VDAZHANG.COM';
bti5=new Image ();bti5.name='QQ: 1063950';
bti6=new Image ();bti6.name='QQ: 1063950';
//定义的图片宽度
w1=new Image ();w1.width='720';
w2=new Image ();w2.width='720';
w3=new Image ();w3.width='720';
w4=new Image ();w4.width='720';
w5=new Image ();w5.width='720';
w6=new Image ();w6.width='720';
//定义的图片高度
h1=new Image ();h1.height='535';
h2=new Image ();h2.height='535';
h3=new Image ();h3.height='535';
h4=new Image ();h4.height='535';
h5=new Image ();h5.height='535';
h6=new Image ();h6.height='535';
var widths=720;var heights=535;var counts=6;var ye=1;var ti=1;var speed=5000;//定义的ye值为1显示数字值为0不显示数字,ti值为1显示标题值为0不显示标题||||speed定义的是速度,counts定义的是图片的数量,和上面的数组个数要对应||||widths和heights是定义的整个框架的宽度和高度
var top;var nn=1;var key=0;var nnnn;
if((ti==1)&&(ye==1))
{top=32;}else{top=16};
function change_img()
{if(key==0){key=1;}
else if(document.all)
{document.getElementById("pic").filters[0].Apply();
document.getElementById("pic").filters[0].Play(duration=2);
document.getElementById("pic").filters[0].Transition=23;};
eval('document.getElementById("pic").src=img'+nn+'.src');
eval('document.getElementById("pic").width=w'+nn+'.width');
eval('document.getElementById("pic").height=h'+nn+'.height');
eval('document.getElementById("url").href=url'+nn+'.src');
if(ti==1){eval('nnnn=bti'+nn+'.name');
document.getElementById("yu").innerHTML='<b>'+nnnn+'<b>';}
if(ye==1){for (var i=1;i<=counts;i++)
{document.getElementById("xxjdjj"+i).className='axx';}
document.getElementById("xxjdjj"+nn).className='bxx';};nn++;if(nn>counts){nn=1;};tt=setTimeout('change_img()',speed);};
function changeimg(n){nn=n;window.clearInterval(tt);change_img();};
document.write('<style>');
document.write('.axx{padding:0px 7px 3px;*padding:1px 7px;border-left:#cccccc 1px solid;}');
document.write('a.axx:link,a.axx:visited{text-decoration:none;color:#fff;line-height:16px;font:10px sans-serif;background-color:#666;}');//非当前图片序号
document.write('a.axx:active,a.axx:hover{text-decoration:none;color:#fff;line-height:16px;font:12px sans-serif;background-color:#999;}');//图片序号指向时大小
document.write('.bxx{padding:0px 7px 3px;*padding:1px 7px;border-left:#cccccc 1px solid;}');
document.write('a.bxx:link,a.bxx:visited{text-decoration:none;color:#fff;line-height:16px;font:12px sans-serif;background-color:#D34600;}');//当前图片序号
document.write('a.bxx:active,a.bxx:hover{text-decoration:none;color:#fff;line-height:16px;font:12px sans-serif;background-color:#D34600;}');//图片序号点击时大小
document.write('</style>');
document.write('<div style="width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;border:#f00 0px solid;">');//此处设置图片区边框
document.write('<div><a id="url"><img id="pic" style="border:0px;filter:progid:DXImageTransform.Microsoft.RevealTrans (duration=2,transition=23);" /></a></div>');
document.write('<div style="filter:alpha(style=1,opacity=30,finishOpacity=80);-moz-opacity:0.8; opacity:0.8;background: #888888;width:100%-2px;text-align:right;top:-'+top+'px;position:relative;margin:1px;height:35px;padding:0px;margin:0px;border:0px;');
if((ye==1)||(ti==1)){document.write('">');}
else{document.write('display:none;">');};
if(ti==1){document.write('<div id="yu" style="filter:alpha(style=1,opacity=100,finishOpacity=30);height:16px;text-align:center;color:#FF00000;background-color:#CED6E9;line-height:16px;"></div>');};
//id=yu的div是显示标题的
if(ye==1){for(var i=1;i<counts+1;i++){document.write('<a href="javascript:changeimg('+i+');" id="xxjdjj'+i+'" class="axx" target="_self">'+i+'</a>');}};document.write('</div></div>');
change_img();</SCRIPT>
若您喜欢这篇文章,欢迎订阅老张小站以获得最新内容。 / 欢迎交流探讨,请发电子邮件至 mail[at]vdazhang.com 。
欢迎谈谈你的看法(无须登录) *正文中请勿包含"http://"否则将被拦截