正解应是这样的: <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <style> a.NUL{ text-decoration: none; color:red; } </style> <SCRIPT LANGUAGE="JavaScript"> <!-- var handler = null; var objHref = null; var index = 0; function showUnderline(){ objHref = event.srcElement; handler = setInterval(drawUnderLine, 50) }function clearUnderline(){ var obj = event.srcElement; obj.innerHTML=obj.innerText; clearInterval(handler); index = 0; }function drawUnderLine(){ if(objHref!=null){ var text = objHref.innerText; var len = text.length; if(index<len){ objHref.innerHTML="<u>"+text.substr(0,++index)+"</u>"+text.substr(index); }else{ clearInterval(handler); index = 0; } } } //--> </SCRIPT> </HEAD> <BODY> <A HREF="#" class="NUL" onmouseover="showUnderline()" onmouseout="clearUnderline()">我爱中华我爱中华我爱中华我爱中华1</A><br> <A HREF="#" class="NUL" onmouseover="showUnderline()" onmouseout="clearUnderline()">我爱中华我爱中华我爱中华我爱中华2</A><br> <A HREF="#" class="NUL" onmouseover="showUnderline()" onmouseout="clearUnderline()">我爱中华我爱中华我爱中华我爱中华3</A><br> <A HREF="#" class="NUL" onmouseover="showUnderline()" onmouseout="clearUnderline()">我爱中华我爱中华我爱中华我爱中华4</A><br> </BODY> </HTML>
CSDN是大家交流,共同进步的好地方。 ---------------------------------------- <script> var aa, dashLine var x = 0 var w, h, m var s = 3 function ani(obj) { var p = getPosition(obj); w = obj.offsetWidth; h = obj.clientHeight;
做一个GIF(渐变,最后帧时间长一点儿)
var aa, dashLine
var x = 0
var w, h, m
var s = 3
function ani(obj) {
var p = getPosition(obj);
w = obj.offsetWidth;
h = obj.clientHeight;
if (dashLine != null)
dashLine.style.display = "block";
else
dashLine = document.createElement("DIV")
dashLine.style.position = "absolute"
dashLine.style.left = p.x + "px"
dashLine.style.top = (p.y+h) + "px"
dashLine.style.width = "1px"
dashLine.style.borderBottom = "1px solid blue"
document.body.appendChild(dashLine)
aa = setInterval(showLine , 10)
}function showLine()
{
if (x <= w)
{
dashLine.style.width = x + "px"
x+=s;
}
}function out() {
clearInterval(aa)
x = 0
dashLine.style.display = "none";
}function getPosition(obj)
{
var x = obj.offsetLeft;
var y = obj.offsetTop;
while(obj = obj.offsetParent)
{
x += obj.offsetLeft;
y += obj.offsetTop;
}
return {x:x, y:y}
}
</script><body>
<p>paragraph , abc <a onmouseover="ani(this)" onmouseout="out(this)" >Blurry text with</a>, wo, <a onmouseover="ani(this)" onmouseout="out(this)" >Blurry</a>
</p>
我爱中华 >> 我爱中华 >> 我爱中华 >> 我爱中华
-- ---- ------ --------我认为,应该是用JS技术来作,这样就不限制有多少字了。
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style>
a.NUL{
text-decoration: none;
color:red;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
var handler = null;
var objHref = null;
var index = 0;
function showUnderline(){
objHref = event.srcElement;
handler = setInterval(drawUnderLine, 50)
}function clearUnderline(){
var obj = event.srcElement;
obj.innerHTML=obj.innerText;
clearInterval(handler);
index = 0;
}function drawUnderLine(){
if(objHref!=null){
var text = objHref.innerText;
var len = text.length;
if(index<len){
objHref.innerHTML="<u>"+text.substr(0,++index)+"</u>"+text.substr(index);
}else{
clearInterval(handler);
index = 0;
}
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<A HREF="#" class="NUL" onmouseover="showUnderline()" onmouseout="clearUnderline()">我爱中华我爱中华我爱中华我爱中华1</A><br>
<A HREF="#" class="NUL" onmouseover="showUnderline()" onmouseout="clearUnderline()">我爱中华我爱中华我爱中华我爱中华2</A><br>
<A HREF="#" class="NUL" onmouseover="showUnderline()" onmouseout="clearUnderline()">我爱中华我爱中华我爱中华我爱中华3</A><br>
<A HREF="#" class="NUL" onmouseover="showUnderline()" onmouseout="clearUnderline()">我爱中华我爱中华我爱中华我爱中华4</A><br>
</BODY>
</HTML>
----------------------------------------
<script>
var aa, dashLine
var x = 0
var w, h, m
var s = 3
function ani(obj) {
var p = getPosition(obj);
w = obj.offsetWidth;
h = obj.clientHeight;
//这里判断一下,避免重复创建
if (dashLine != null)
{
dashLine.style.display = "block";
}
else
{
dashLine = document.createElement("DIV")
dashLine.style.position = "absolute"
dashLine.style.borderBottom = "1px solid blue"
document.body.appendChild(dashLine)
}
//下划线的位置,初始长度
dashLine.style.left = p.x + "px"
dashLine.style.top = (p.y+h) + "px"
dashLine.style.width = "1px" //开始循环增加下划线的长度
aa = setInterval(showLine , 10)
}function showLine()
{
//w即为当前超链接的长度(未考虑换行的情形,比较复杂)
if (x <= w)
{
dashLine.style.width = x + "px"
x+=s;
}
}function out() {
clearInterval(aa)
x = 0
dashLine.style.display = "none";
}function getPosition(obj) //这基本上算是个很通用的方法
{
var x = obj.offsetLeft;
var y = obj.offsetTop;
while(obj = obj.offsetParent)
{
x += obj.offsetLeft;
y += obj.offsetTop;
}
return {x:x, y:y}
}
</script><body>
<p>paragraph , abc <a onmouseover="ani(this)" onmouseout="out(this)" >abc中文</a>, wo, <a onmouseover="ani(this)" onmouseout="out(this)" >Blurry</a>
</p>