问问怎么实现鼠标悬停,就象新浪上的新闻一样,当鼠标一停那里,新闻就不动了,就可以点击了

dylyonia 2003-12-26 02:37:30
就是跑马灯显示新闻后,当你的鼠标点到这一条的时候,新闻条不动了,可以让你点击了
...全文
309 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
m117zerozhang 2010-06-16
  • 打赏
  • 举报
回复
我们公司现在要更新一个程序,我是个JAVASCRIPT 的新手,对这样的程序没有什么太多的理解,现在我有一个程序,请高手分析好吗?


<!--
/*JS Marquee Version 1.2(Javascript实现Marquee的效果,实现无缝/有间隙的二维滚动效果)*/
/*Author : ChenReal
Email : chenreal@21cn.com
Date : 2007-10-22*/
function Marquee(MarName)
{
this.ID = document.getElementById(MarName);
this.Speed = 30; //数字越大速度越慢
this.Direction = 0;//滚动方向:0代表左;1代表右;2代表上;3代表下
this.Width = 0;//高度
this.Height = 0;//宽度
this.Space = 0;//是否有间隙:0代表否;1代表是
this.Tag = "p";//滚动内容的标签,默认是<p>,也可以是<ul>,实践证明:<p>与<ul>不能嵌套使用。其他标签暂时不推荐。
//开始滚动
this.Start = function(){
MarqueeStart(this,this.Direction,this.Width,this.Height,this.Speed,this.Space,this.Tag);
}
//停止滚动并释放对象
this.End = function(){
MarqueeEnd(this);
}
}
function MarqueeStart(Mar,Direction,Width,Height,Speed,Space,Tag){
var msobj;
if(typeof(Mar) == "string"){
msobj = new Marquee(Mar);
}
if(typeof(Mar) == "object"){
msobj = Mar;
}
if(!msobj.ID) return;
msobj.ID.style.width = Width + "px";
msobj.ID.style.height = Height + "px";
msobj.ID.style.overflow = msobj.ID.style.overflowX = msobj.ID.style.overflowY = "hidden";
msobj.Direction = Direction;
msobj.Width = Width;
msobj.Height = Height;
msobj.Speed = Speed;
msobj.Space = Space;
msobj.Tag = Tag;
msobj.InnerDiv = msobj.ID.getElementsByTagName("div")[0];
if(!msobj.InnerDiv) return;
msobj.InnerDiv.innerHTML += msobj.InnerDiv.innerHTML;
msobj.Inner = msobj.ID.getElementsByTagName(Tag);
if(!msobj.Inner) return;
switch(Direction)
{
case 2:
msobj.InnerDiv.style.width = Width + "px";
msobj.Inner[0].style.width =Width + "px";
msobj.Inner[1].style.width =Width + "px";
if(Height>=msobj.Inner[1].offsetHeight || msobj.Space ==1){
msobj.Inner[0].style.paddingTop = Height + "px";
msobj.Inner[1].style.paddingTop = Height + "px";;
}
break;
case 3:
msobj.InnerDiv.style.width = Width + "px";
msobj.Inner[0].style.width =Width + "px";
msobj.Inner[1].style.width =Width + "px";
if(Height>=msobj.Inner[1].offsetHeight || msobj.Space ==1){
msobj.Inner[0].style.paddingBottom = Height + "px";
msobj.Inner[1].style.paddingBottom = Height + "px";
}
break;
default:
msobj.InnerDiv.noWrap = true;
if(Width >= msobj.Inner[1].offsetWidth || msobj.Space ==1){
msobj.Inner[0].style.paddingLeft = Width + "px";
msobj.Inner[1].style.paddingLeft = Width + "px";
}
break;
}

msobj.ID.onmouseover = function(){
clearInterval(msobj.TimerID);
}

msobj.ID.onmouseout = function(){
clearInterval(msobj.TimerID);
msobj.TimerID = funcInterval(MarqueeScroll,msobj.Speed,msobj);
}
msobj.TimerID = funcInterval(MarqueeScroll,msobj.Speed,msobj);

}
function MarqueeScroll(Mar){
switch(Mar.Direction)
{
case 0:
if(Mar.Inner[1].offsetWidth-Mar.ID.scrollLeft<=0)
Mar.ID.scrollLeft-=Mar.Inner[0].offsetWidth;
else{
Mar.ID.scrollLeft++;
}
break;
case 1:
if(Mar.ID.scrollLeft==0)
Mar.ID.scrollLeft=Mar.Inner[1].offsetWidth;
else{
Mar.ID.scrollLeft--;
}
break;
case 2:
if(Mar.Inner[1].offsetHeight-Mar.ID.scrollTop<=0)
Mar.ID.scrollTop-=Mar.Inner[0].offsetHeight;
else{
Mar.ID.scrollTop++;
}
break;
case 3:
if(Mar.ID.scrollTop<=0)
Mar.ID.scrollTop = Mar.Inner[1].offsetHeight;
else{
Mar.ID.scrollTop--;
}
break;
}
}
function MarqueeEnd(Mar){
if(!Mar)return;
if(typeof(Mar.TimerID) == "number") {
clearInterval(Mar.TimerID);
Mar = null;
}
}
function funcInterval(funcName,time){
var args=[];
for(var i=2;i<arguments.length;i++){
args.push(arguments[i]);
}
return window.setInterval(function(){
funcName.apply(this,args);
},time);
}
//-->
dylyonia 2003-12-26
  • 打赏
  • 举报
回复
好,谢谢!结贴
say1no2 2003-12-26
  • 打赏
  • 举报
回复
晕,不是吧!到这份上了,还不会?!!!

<%
set rs=conn.execute("select * from .......")
%>
<marquee direction="left" scrollamount="10" onMouseOver="stop()" onMouseOut="start()">
<%=rs("xxxxx")%>
</marquee>
luluso 2003-12-26
  • 打赏
  • 举报
回复
<table width="776" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td><marquee behavior="scroll" scrollDelay=80 scrollamount="5" onmouseover="this.stop()" onmouseout="this.start()"><%=rs("表字段")%> </marquee> </td>
</tr>
</table>
/////////
<%=rs("表字段")%>
取库的内容并显示,点击并停止.
dylyonia 2003-12-26
  • 打赏
  • 举报
回复
而且我的新闻是数据库里调出来的
dylyonia 2003-12-26
  • 打赏
  • 举报
回复
我只要文字移动就行了
回xupiao(不看連續劇
我会很快结贴的,谢谢
xupiao 2003-12-26
  • 打赏
  • 举报
回复
如果可以請結帖
sxsgssgs 2003-12-26
  • 打赏
  • 举报
回复
还是用下面的这一段吧,比前边的更好一点。
<table width="776" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td><marquee behavior="scroll" scrollDelay=80 scrollamount="5" onmouseover="this.stop()" onmouseout="this.start()">
<a href="aaa.asp"><IMG src="picture.gif" border=0>这就是图片和文字一块移动</a>
</marquee> </td>
</tr>
</table>
say1no2 2003-12-26
  • 打赏
  • 举报
回复
用上面的代码就可以了
sxsgssgs 2003-12-26
  • 打赏
  • 举报
回复
还是用下面的这一段吧,比前边的更好一点。
<table width="776" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td><marquee behavior="scroll" scrollDelay=80 scrollamount="5" onmouseover="this.stop()" onmouseout="this.start()">
<a href="aaa.asp"><IMG src="picture.gif" border=0>这就是图片和文字一块移动</a>
</marquee> </td>
</tr>
</table>
say1no2 2003-12-26
  • 打赏
  • 举报
回复
<marquee direction="left" scrollamount="10" onMouseOver="stop()" onMouseOut="start()">
<a href="#">dssfsdfsdf</a> <a href="#">dssfsdfsdf</a>
</marquee>
hnjava 2003-12-26
  • 打赏
  • 举报
回复
onmousemove=stop()
sxsgssgs 2003-12-26
  • 打赏
  • 举报
回复
<table width="776" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td><marquee behavior="scroll" scrollDelay=80 scrollamount="5" onmouseover="this.stop()" onmouseout="this.start()">
<IMG onmouseover=stop=1;
onmouseout=stop=0; src="picture.gif" border=0>这就是图片和文字一块移动
</marquee> </td>
</tr>
</table>

把这一段拷到你新建的网里,保存然后浏览,看看效果。就知道了。
sxsgssgs 2003-12-26
  • 打赏
  • 举报
回复
<IMG onmouseover=stop=1;
onmouseout=stop=0; src="picture.gif" border=0>

这个就没问题了。
dylyonia 2003-12-26
  • 打赏
  • 举报
回复
欧,
hrh1979 2003-12-26
  • 打赏
  • 举报
回复
onmousemove事件中,让其停止运动就行了。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧