这篇文章主要介绍了 JS 实现把鼠标放到链接上出现滚动文字的方法, 涉及 JavaScript 响应鼠标事件动态操作页面元素的相关技巧, 需要的朋友可以参考下
Javascript 是一种由 Netscape 的 LiveScript 发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如 Perl,遗留的速度问题,为客户提供更流畅的浏览效果。
本文实例讲述了 JS 实现把鼠标放到链接上出现滚动文字的方法。分享给大家供大家参考,具体如下:
- <div id="tooltip2" style="position:absolute;visibility:hidden;clip:rect(0 150 50 0);width:150px;background-color:seashell">
- <layer name="nstip" width=1000px bgColor="seashell"></layer>
- </div>
- <SCRIPT language="JavaScript">
- <!--
- if (!document.layers&&!document.all)
- event="test"
- function showtip2(current,e,text){
- if (document.all&&document.readyState=="complete"){
- document.all.tooltip2.innerhtml='<marquee style="border:1px solid black">'+text+'</marquee>'
- document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10
- document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10
- document.all.tooltip2.style.visibility="visible"
- }
- else if (document.layers){
- document.tooltip2.document.nstip.document.write('<b>'+text+'</b>')
- document.tooltip2.document.nstip.document.close()
- document.tooltip2.document.nstip.left=0
- currentscroll=setInterval("scrolltip()",100)
- document.tooltip2.left=e.pageX+10
- document.tooltip2.top=e.pageY+10
- document.tooltip2.visibility="show"
- }
- }
- function hidetip2(){
- if (document.all)
- document.all.tooltip2.style.visibility="hidden"
- else if (document.layers){
- clearInterval(currentscroll)
- document.tooltip2.visibility="hidden"
- }
- }
- function scrolltip(){
- if (document.tooltip2.document.nstip.left>=-document.tooltip2.document.nstip.document.width)
- document.tooltip2.document.nstip.left-=5
- else
- document.tooltip2.document.nstip.left=150
- }
- //-->
- </SCRIPT>
- <a href=# onMouseOver="showtip2(this,event,'看到了吧?')" onMouseOut="hidetip2()">把鼠标放上来试试</a>
希望本文所述对大家 JavaScript 程序设计有所帮助。
来源: http://www.phperz.com/article/17/0219/266404.html