百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>JS教程> js焦点图广告代码
分享文章到:

js焦点图广告代码

发布时间:01/15 来源: 浏览: 关键词:
这是一款js焦点图广告代码哦,他像淘宝、土豆网JS图片切换特效等很多在网站的广告切换效果代码哦,如果你正在急着找广告代码类似于flash广告切换效果这款很不错,同时提供免费下载与在线效果预览。
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>广告代码_http://www.111cn.net</title>
<style type="text/css教程">
/* reset style */
* { margin:0; padding:0; word-break:break-all; }
body { background:#fff; color:#333; font:12px/1.6em helvetica, arial, sans-serif; }
h1, h2, h3, h4, h5, h6 { font-size:1em; }
a { color:#039; text-decoration:none; }
 a:hover { text-decoration:underline; }
ul, li { list-style:none; }
fieldset, img { border:none; }
em, strong, cite, th { font-style:normal; font-weight:normal; }
/* focus_change style */
#focus_change { position:relative; width:450px; height:295px; overflow:hidden; margin:20px 0 1px 60px; }
 #focus_change_list { position:absolute; width:1800px; height:295px; }
  #focus_change_list li { float:left; }
  #focus_change_list li img { width:450px; height:295px; }
 .focus_change_opacity { position:absolute; width:450px; height:70px; top:225px; left:0; background:#000; filter:alpha(opacity=50); -moz-opacity:0.5; opacity: 0.5; }
 #focus_change_btn { position:absolute; width:450px; height:65px; top:225px; left:0; }
  #focus_change_btn ul { padding-left:5px; }
  #focus_change_btn li { display:inline; float:left; margin:0 15px; padding-top:12px; }
  #focus_change_btn li img { width:76px; height:50px; border:2px solid #888; }
  #focus_change_btn .current { background:url(icon_arrow.gif) no-repeat 37px 8px;}
  #focus_change_btn .current img { border-color:#eee; }
</style>
<script type="text/网页特效">
function $(id) { return document.getelementbyid(id); }
function moveelement(elementid,final_x,final_y,interval) {
  if (!document.getelementbyid) return false;
  if (!document.getelementbyid(elementid)) return false;
  var elem = document.getelementbyid(elementid);
  if (elem.movement) {
    cleartimeout(elem.movement);
  }
  if (!elem.style.left) {
    elem.style.left = "0px";
  }
  if (!elem.style.top) {
    elem.style.top = "0px";
  }
  var xpos = parseint(elem.style.left);
  var ypos = parseint(elem.style.top);
  if (xpos == final_x  &&  ypos == final_y) {
  return true;
  }
  if (xpos < final_x) {
    var dist = math.ceil((final_x - xpos)/10);
    xpos = xpos + dist;
  }
  if (xpos > final_x) {
    var dist = math.ceil((xpos - final_x)/10);
    xpos = xpos - dist;
  }
  if (ypos < final_y) {
    var dist = math.ceil((final_y - ypos)/10);
    ypos = ypos + dist;
  }
  if (ypos > final_y) {
    var dist = math.ceil((ypos - final_y)/10);
    ypos = ypos - dist;
  }
  elem.style.left = xpos + "px";
  elem.style.top = ypos + "px";
  var repeat = "moveelement('"+elementid+"',"+final_x+","+final_y+","+interval+")";
  elem.movement = settimeout(repeat,interval);
}
function classnormal(){
 var focusbtnlist = $('focus_change_btn').getelementsbytagname('li');
 for(var i=0; i<focusbtnlist.length; i++) {
  focusbtnlist[i].classname='';
 }
}
function focuschange() {
 var focusbtnlist = $('focus_change_btn').getelementsbytagname('li');
  focusbtnlist[0].onmouseo教程ver = function() {
   moveelement('focus_change_list',0,0,5);
   classnormal()
   focusbtnlist[0].classname='current'
  }
  focusbtnlist[1].onmouseover = function() {
   moveelement('focus_change_list',-450,0,5);
   classnormal()
   focusbtnlist[1].classname='current'
  }
  focusbtnlist[2].onmouseover = function() {
   moveelement('focus_change_list',-900,0,5);
   classnormal()
   focusbtnlist[2].classname='current'
  }
  focusbtnlist[3].onmouseover = function() {
   moveelement('focus_change_list',-1350,0,5);
   classnormal()
   focusbtnlist[3].classname='current'
  }
}
setinterval('autofocuschange()', 5000);
function autofocuschange() {
 var focusbtnlist = $('focus_change_btn').getelementsbytagname('li');
 for(var i=0; i<focusbtnlist.length; i++) {
  if (focusbtnlist[i].classname == 'current') {
   var currentnum = i;
  }
 }
 if (currentnum==0 ){
  moveelement('focus_change_list',-450,0,5);
  classnormal()
  focusbtnlist[1].classname='current'
 }
 if (currentnum==1 ){
  moveelement('focus_change_list',-900,0,5);
  classnormal()
  focusbtnlist[2].classname='current'
 }
 if (currentnum==2 ){
  moveelement('focus_change_list',-1350,0,5);
  classnormal()
  focusbtnlist[3].classname='current'
 }
 if (currentnum==3 ){
  moveelement('focus_change_list',0,0,5);
  classnormal()
  focusbtnlist[0].classname='current'
 }
}
window.onload=function(){
 focuschange();
}
</script>
</head>
<body>
<div id="focus_change">
 <div id="focus_change_list" style="top:0; left:0;">
  <ul>
  <li><img src="img/01.jpg"/></li>
  <li><img src="img/02.jpg"/></li>
  <li><img src="img/03.jpg"/></li>
  <li><img src="img/04.jpg"/></li>
  </ul>
 </div>
 <div class="focus_change_opacity"></div>
 <div id="focus_change_btn">
  <ul>
  <li class="current"><a href="#"><img src="img/btn_01.jpg" alt="" /></a></li>
  <li><a href="#"><img src="img/btn_02.jpg"/></a></li>
  <li><a href="#"><img src="img/btn_03.jpg"/></a></li>
  <li><a href="#"><img src="img/btn_04.jpg"/></a></li>
  </ul>
 </div>
</div><!--focus_change end-->
<br />
<a href="http://www.111cn.net/" target="_blank" style="font-size:14px; color:#003366; margin-left:180px;">整理自壹聚教程网</a>
</body>
</html>

源码下载地址
http://down.111cn.net/down/code/js/xiangcedaima/2010/0911/20752.html

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有6人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板