图片自动切换——javascript的代码

来源:互联网 发布:bugku sql注入1 编辑:程序博客网 时间:2024/05/17 06:39

<textarea cols="50" rows="15" name="code" class="javascript">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head&gt;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;&lt;title&gt;热销产品&lt;/title&gt;&lt;mce:style type=&quot;text/css&quot;&gt;&lt;!--/* Reset style */* { margin:0; padding:0; word-break:break-all; }body { background:#CCCCCC; color:#CCCCCC; 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:10px 0 1px 10px; } #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(img/hotgoods.jpg) no-repeat 37px 8px;} #focus_change_btn .current img { border-color:#EEE; }--&gt;&lt;/mce:style&gt;&lt;style type=&quot;text/css&quot; mce_bogus=&quot;1&quot;&gt;/* Reset style */* { margin:0; padding:0; word-break:break-all; }body { background:#CCCCCC; color:#CCCCCC; 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:10px 0 1px 10px; } #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(img/hotgoods.jpg) no-repeat 37px 8px;} #focus_change_btn .current img { border-color:#EEE; }&lt;/style&gt;&lt;mce:script type=&quot;text/javascript&quot;&gt;&lt;!--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 = &quot;0px&quot;; } if (!elem.style.top) { elem.style.top = &quot;0px&quot;; } var xpos = parseInt(elem.style.left); var ypos = parseInt(elem.style.top); if (xpos == final_x &amp;&amp; ypos == final_y) { return true; } if (xpos &lt; final_x) { var dist = Math.ceil((final_x - xpos)/10); xpos = xpos + dist; } if (xpos &gt; final_x) { var dist = Math.ceil((xpos - final_x)/10); xpos = xpos - dist; } if (ypos &lt; final_y) { var dist = Math.ceil((final_y - ypos)/10); ypos = ypos + dist; } if (ypos &gt; final_y) { var dist = Math.ceil((ypos - final_y)/10); ypos = ypos - dist; } elem.style.left = xpos + &quot;px&quot;; elem.style.top = ypos + &quot;px&quot;; var repeat = &quot;moveElement('&quot;+elementID+&quot;',&quot;+final_x+&quot;,&quot;+final_y+&quot;,&quot;+interval+&quot;)&quot;; elem.movement = setTimeout(repeat,interval);}function classNormal(){ var focusBtnList = $('focus_change_btn').getElementsByTagName('li'); for(var i=0; i&lt;focusBtnList.length; i++) { focusBtnList[i].className=''; }}function focusChange() { var focusBtnList = $('focus_change_btn').getElementsByTagName('li'); focusBtnList[0].onmouseover = 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);var atuokey = false;function autoFocusChange() { $('focus_change').onmouseover = function(){atuokey = true} $('focus_change').onmouseout = function(){atuokey = false} if(atuokey) return; var focusBtnList = $('focus_change_btn').getElementsByTagName('li'); for(var i=0; i&lt;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();}// --&gt;&lt;/mce:script&gt;&lt;/head&gt;&lt;body bgcolor=&quot;#cccccc&quot; topmargin=&quot;0&quot;&gt;&lt;div id=&quot;focus_change&quot; style=&quot;background-color:#CCCCCC&quot; mce_style=&quot;background-color:#CCCCCC&quot;&gt;&lt;div id=&quot;focus_change_list&quot; style=&quot;top:0; left:0;color:#CCCCCC&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;img src=&quot;img/hotgoods01.jpg&quot; mce_src=&quot;img/hotgoods01.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;&lt;li&gt;&lt;img src=&quot;img/hotgoods02.jpg&quot; mce_src=&quot;img/hotgoods02.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;&lt;li&gt;&lt;img src=&quot;img/hotgoods03.jpg&quot; mce_src=&quot;img/hotgoods03.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;&lt;li&gt;&lt;img src=&quot;img/hotgoods04.jpg&quot; mce_src=&quot;img/hotgoods04.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class=&quot;focus_change_opacity&quot;&gt;&lt;/div&gt;&lt;div id=&quot;focus_change_btn&quot;&gt;&lt;ul&gt;&lt;li class=&quot;current&quot;&gt;&lt;a href=&quot;#&quot; mce_href=&quot;#&quot;&gt;&lt;img src=&quot;img/hotgoods01.jpg&quot; mce_src=&quot;img/hotgoods01.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#&quot; mce_href=&quot;#&quot;&gt;&lt;img src=&quot;img/hotgoods02.jpg&quot; mce_src=&quot;img/hotgoods02.jpg&quot; width=&quot;78&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#&quot; mce_href=&quot;#&quot;&gt;&lt;img src=&quot;img/hotgoods03.jpg&quot; mce_src=&quot;img/hotgoods03.jpg&quot; width=&quot;78&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#&quot; mce_href=&quot;#&quot;&gt;&lt;img src=&quot;img/hotgoods04.jpg&quot; mce_src=&quot;img/hotgoods04.jpg&quot; width=&quot;78&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;!--focus_change end--&gt;&lt;/body&gt;&lt;/html&gt;</textarea>

over

原创粉丝点击