兼容性好的图片滚动代码,能否分享一下?[问题已解决,加给175版主50分!]
谢谢您![ 本帖最后由 tepnidh 于 2010-7-22 17:00 编辑 ]
<style> .dhMarquee {width:120px;height:450px;text-align:center;margin:0px;padding:0px;border:1px solid #000;overflow:hidden;white-space:nowrap;} .mqdemo {margin:0px auto;padding:0px;border:0px;} .dhScrollA {font-size:12px;display:block;padding:2px;} </style> <div id="mq" class="dhMarquee" onmouseover="iScrollAmount=0" onmouseout="iScrollAmount=1"> <div id="mqdemo" class="mqdemo"> <a class="dhScrollA" href="javascript:alert('1')"><img src='1.jpg' width='100px' height='100px'/></a> <a class="dhScrollA" href="javascript:alert('2')"><img src='2.jpg' width='100px' height='100px'/></a> <a class="dhScrollA" href="javascript:alert('3')"><img src='3.jpg' width='100px' height='100px'/></a> </div> </div> <script language="javascript"> var speed = 10; //滚动对象 var oMarquee = document.getElementById("mq"); //内容对象 var omqdemo = document.getElementById("mqdemo"); var w = oMarquee.offsetHeight; var odl = omqdemo.offsetHeight; var x = parseInt(w/odl)+1; for(var i=0;i<x;i++){ var o = omqdemo.cloneNode(true); oMarquee.appendChild(o); } var iScrollAmount = 1 function scroll(){ oMarquee.scrollTop += iScrollAmount; var ol = oMarquee.scrollTop; if(odl-ol<=0){ oMarquee.scrollTop = 0; } } var MyMar = window.setInterval(scroll,speed); </script>
<style> a {font-size:12px;} .dhMarquee { width:500px; height:110px; line-height:110px; text-align:center; margin:0px; padding-top:8px; *_padding-top:4px;/*IE*/ border:1px solid #000; overflow:hidden; white-space:nowrap;} .mqdemo {margin:0px;padding:0px;border:0px;} .dhScrollA img{border:0px;} </style> <div id="mq" class="dhMarquee" onmouseover="iScrollAmount=0" onmouseout="iScrollAmount=1"> <span id="mqdemo" class="mqdemo"> <a class="dhScrollA" href="javascript:alert('1')"><img src='1.jpg' width='100px' height='100px'/></a> <a class="dhScrollA" href="javascript:alert('2')"><img src='2.jpg' width='100px' height='100px'/></a> <a class="dhScrollA" href="javascript:alert('3')"><img src='3.jpg' width='100px' height='100px'/></a> </span> </div> <script language="javascript"> var speed = 90; //判断浏览器类型 var isMSIE = (navigator.appName == "Microsoft Internet Explorer"); //滚动对象 var oMarquee = document.getElementById("mq"); //内容对象 var omqdemo = document.getElementById("mqdemo"); var w = oMarquee.offsetWidth; var odl = omqdemo.offsetWidth; var x = parseInt(w/odl)+1; for(var i=0;i<x;i++){ var o = omqdemo.cloneNode(true); oMarquee.appendChild(o); } var iScrollAmount = 1 function scroll(){ oMarquee.scrollLeft += iScrollAmount; var ol = oMarquee.scrollLeft; //IE和FF的位置有不同 if(isMSIE){ if(odl-ol<=0){ oMarquee.scrollLeft = 0; } } else{ if(odl-ol<=-10){ oMarquee.scrollLeft = 2; } } } var MyMar = window.setInterval(scroll,speed); </script>