日期:2014-05-16  浏览次数:20434 次

求问这个JS在IE无效的解决方法啊。。。。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<style>
.selectd{
border:solid 1px blue;
background-color:#Fa13b1;
color:Yellow;
}
.unselected{
background-color:white;
color:black;
}
#inputdiv{
border:solid 1px #00dbac;
position:fixed;
left:70%;
}
#content{
padding:20px;
border:solid 1px #00aaac;
}

</style>

<script>
var words;
var env;
var content;
var scrollY = 0;
var direction=0
function select(){

    words=document.getElementById('intxt').value;
if(words.length>=3){
setblack();
serach(words);
}
}

function setblack(){
var as=document.getElementsByTagName('span');
for(var i=0;i<as.length;i++){
as[i].className="unselected";
}
}
function serach(words){
env=document.getElementById(words);

if(env == null){
alert("没有"+words+"这个栏目")
}else{
if(env.offsetTop>= scrollY +100){
direction=0;
}else if(env.offsetTop<=scrollY-100){
direction=1;
}
scrollWindow();
var name=document.getElementById(words+'_name');
name.className="selectd";
}

}


function scrollWindow()
{//欢迎来到站长特效网,我们的网址是www.zzjs.net,很好记,zz站长,js就是js特效,本站收集大量高质量js代码,还有许多广告代码下载。
if (direction == 0)
{

if ( env.offsetTop>= scrollY +100){
window.scrollBy(0,+10);
scrollY=scrollY + 10;
}else{
clearTimeout(srcoll);
}
}
else{

if ( env.offsetTop<=scrollY){
window.scrollBy(0,-10);
scrollY=scrollY - 10;
}else{
clearTimeout(srcoll);
}
}
  var srcoll=setTimeout("scrollWindow()", 10);
  }//欢迎来到站 
</script>
</head>
<body>
<div id="inputdiv">
<input type="text" id="intxt" /><br />
<a href="javascript:void(0)" onclick="select();">turn in</a>
</div>
<div id="content">
<a id="constanine"></a><span id="constanine_name">constanine</span>
*************************************************<br />
*************************************************<br />
*************************************************<br />