| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1047 人关注过本帖
标题:两个脚本出现冲突了,各位高手帮我看看怎么改?
只看楼主 加入收藏
绿柳红樱
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-9-10
结帖率:100%
收藏
 问题点数:0 回复次数:3 
两个脚本出现冲突了,各位高手帮我看看怎么改?
在写脚本的时候两个脚本出现冲突,不知道要怎么改才可以,望各位好心人帮帮看看!!!!红色脚本和蓝色脚本出现冲突了,为什么会这样啊?我试了一下,把两个onload那里改掉可以用一个,我的第一个脚本是要实现层的滚动,第二个是要鼠标效果!!!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>

<script >
var tips;
var theTop = 10; /*这是默认高度,越大越往下*/
var old = theTop;
var xjp;
var theTop1 = 10; /*这是默认高度,越大越往下*/
var old1 = theTop1;


function moveTips() {
    var tt = 0;
    if (window.innerHeight) {
        pos = window.pageYOffset
    } else if (document.documentElement && document.documentElement.scrollTop) {
        pos = document.documentElement.scrollTop
    } else if (document.body) {
        pos = document.body.scrollTop;
    }

    pos = pos - tips.offsetTop + theTop;
    pos=tips.offsetTop+pos/10;
    if (pos < theTop) pos = theTop;
    if (pos != old) {
        tips.style.top = pos+"px";
        tt = 0;
    }
    old = pos;
    setTimeout(moveTips,tt);
}
function movexjp() {
    var tt1 = 0;
    if (window.innerHeight) {
        pos1 = window.pageYOffset
    } else if (document.documentElement && document.documentElement.scrollTop) {
        pos1 = document.documentElement.scrollTop
    } else if (document.body) {
        pos1 = document.body.scrollTop;
    }

    if (pos1 < theTop1) pos1 = theTop1;
    if (pos1 != old1) {
    pos1 = pos1 - xjp.offsetTop + theTop1;
    pos1=xjp.offsetTop+pos1/10;
        xjp.style.top = pos1+"px";
        tt1 = 0;
    }
    old1 = pos1;
    setTimeout(movexjp,tt1);
}

onload = function initFloatxjp() {
   tips = document.getElementById('left');
    moveTips();

    xjp = document.getElementById('weight');
    movexjp();
};
</script>

<script>
yourLogo='欢 迎  光 临 软 件 开 发 一 班';
logoFont='Arial';
logoSize=9;
logoColor='red';
logoWidth=40;
logoHeight=40;
logoSpeed=0.03;
//Nothing needs altering below!
yourLogo=yourLogo.split('');
L=yourLogo.length;
Result="<font face="+logoFont+" style='font-size:"+logoSize+"pt' color="+logoColor+">";
TrigSplit=360/L;
br=(document.layers)?1:0;
if (br){
for (i=0; i < L; i++)
document.write('<layer name="ns'+i+'" top=0 left=0 width=14 height=14">'+Result+yourLogo[i]+'</layer>');
}
else{
document.write('<div id="outer" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < L; i++)
document.write('<div id="ie" style="position:absolute;top:0px;left:0px;width:14px;height:14px">'+Result+yourLogo[i]+'</div>');
document.write('</div></div>');
}
ypos=0;
xpos=0;
step=logoSpeed;
currStep=0;
Y=new Array();
X=new Array();
Yn=new Array();
Xn=new Array();
for (i=0; i < L; i++)
 {
 Yn[i]=0;
 Xn[i]=0;
 }
(document.layers)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt){
 ypos = (document.layers)?evnt.pageY:event.y;
 xpos = (document.layers)?evnt.pageX:event.x;
}
(document.layers)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
function animateLogo(){
if (!br)outer.style.pixelTop=document.body.scrollTop;
for (i=0; i < L; i++){
var layer=(document.layers)?document.layers['ns'+i]:ie[i].style;
layer.top =Y[i]+logoHeight*Math.sin(currStep+i*TrigSplit*Math.PI/180);
layer.left=X[i]+logoWidth*Math.cos(currStep+i*TrigSplit*Math.PI/180);
}
currStep-=step;
}
function Delay(){
for (i=L; i >= 0; i--)
{
Y[i]=Yn[i]+=(ypos-Yn[i])*(0.1+i/L);           
X[i]=Xn[i]+=(xpos-Xn[i])*(0.1+i/L);        
}
animateLogo();
setTimeout('Delay()',20);
}
window.onload=Delay;



</script>
<style type="text/css">
<!--
.Layer1 {
    position:absolute;    
    left:11px;
    top:15px;
    width:91px;
    height:790px;
    z-index:1;
}
.Layer2 {
    position:absolute;
    left:928px;
    top:14px;
    width:97px;
    height:788px;
    z-index:2;
}
body {
    background-image: url(beijin.jpg);
}
-->
<!--
body, td, div { font-family: Verdana; font-size: 9pt }
-->
</style>
</head>
<body>
<div id="left" class="Layer1">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.,0,19,0" width="89" height="790">
    <param name="movie" value="励志照亮人生.swf" />
    <param name="quality" value="high" />
    <embed src="励志照亮人生.swf" quality="high" pluginspage="http://www. type="application/x-shockwave-flash" width="89" height="790"></embed>
  </object>
</div>
<div id="weight" class="Layer2">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.,0,19,0" width="97" height="789">
    <param name="movie" value="编程改变命运.swf" />
    <param name="quality" value="high" />
    <embed src="编程改变命运.swf" quality="high" pluginspage="http://www. type="application/x-shockwave-flash" width="97" height="789"></embed>
  </object>
</div>
<table width="79%" align="center">
  <tr>
    <td colspan="2"><img src="软件开发一班.jpg" width="800" height="150" /></td>
  </tr>
  
  <tr>
    <td colspan="2"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.,0,19,0" width="799" height="41">
      <param name="movie" value="xjp导航.swf" />
      <param name="quality" value="high" />
      <embed src="xjp导航.swf" quality="high" pluginspage="http://www. type="application/x-shockwave-flash" width="799" height="41"></embed>
    </object></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  
  <tr>
    <td width="40%"><table width="100%">
      <tr>
        <td>    <div id="hotImg">
            <style type="text/css">
          .bigon{background:url(http://mat1.);color:#FFF; line-height:18px;}
          .bigoff{background:url(http://mat1.);color:#000; line-height:18px;}
          a.bla{color:#000; text-decoration:none}
          a.bla:hover{color:#F00; text-decoration:underline}
          </style>
            <table width="312" border="0" align="left" cellpadding="0" cellspacing="0">
            <tr>
              <td width="312"><div id="fc" style="width:310px;height:210px;filter:progid:DXImageTransform.Microsoft.Fade ( duration=0.5,overlap=1.0 );">

 <div style="display:block;">


<a href="" target="_blank"><img src="junxun.JPG" width="310" height="210" border="0"
onMouseOver="clearAuto();" onMouseOut="setAuto()" /></a></div>
<div style="display:none;">
<a href="" target="_blank"><img src="gewuji.JPG" width="310" height="210" border="0"
onMouseOver="clearAuto();" onMouseOut="setAuto()" /></a></div>
<div style="display:none;">
<a href="" target="_blank"><img src="tanrihoudong.JPG" width="310" height="210" border="0"
onMouseOver="clearAuto();" onMouseOut="setAuto()" /></a></div>
<div style="display:none;">
<a href="" target="_blank"><img src="yuansudebanhui.jpg" width="310" height="210" border="0"
onMouseOver="clearAuto();" onMouseOut="setAuto()" /></a></div>
</div></td>
            </tr>
            <tr>
              <td height="26" ><table width="310" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="253" align="center"  onmouseover="clearAuto();" onMouseOut="setAuto()"><div id="con">

<div style="display:block;">
<a href="" target="_blank" class="bla">广州大学华软软件学院2007年军训</a></div>
<div style="display:none;">
<a href="" target="_blank" class="bla">精彩的2007届软件开发一班的表演</a></div>
<div style="display:none;">
<a href="" target="_blank" class="bla">丰富的的团日活动</a></div>
<div style="display:none;">
<a href="" target="_blank" class="bla">5.12我们的哀悼</a></div>
</div>
</td>
<td width="57"><table border="0" align="center" cellpadding="0" cellspacing="4" class="lhn" id="num">
<tr>
<td width="14" height="18" align="center"  class="bigon" onclick="Mea(0);" onmouseover="clearAuto();" onmouseout="setAuto()" style="cursor:pointer;">1</td>
<td width="14" align="center"  class="bigoff" onclick="Mea(1);" onmouseover="clearAuto();" onmouseout="setAuto()" style="cursor:pointer;">2</td>
<td width="14" align="center"  class="bigoff" onclick="Mea(2);" onmouseover="clearAuto();" onmouseout="setAuto()" style="cursor:pointer;">3</td>
<td width="14" align="center"  class="bigoff" onclick="Mea(3);" onmouseover="clearAuto();" onmouseout="setAuto()" style="cursor:pointer;">4</td>
                    </tr>
                    </table></td>
                  </tr>
              </table></td>
            </tr>
</table>
    <script>
var n=0;
var showNum = document.getElementById("num");
function Mea(value){
    n=value;
    setBg(value);
    plays(value);
    cons(value);
    }
function setBg(value){
    for(var i=0;i<4;i++)
   if(value==i){
        showNum.getElementsByTagName("td")[i].className='bigon';
        }
    else{    
        showNum.getElementsByTagName("td")[i].className='bigoff';
        }  
    }
function plays(value){
    try
    {
        with (fc)
        {
            filters[0].Apply();
            for(i=0;i<4;i++)i==value?children[i].style.display="block":children[i].style.display="none";
            filters[0].play();
        }
    }
    catch(e)
    {
        var divlist = document.getElementById("fc").getElementsByTagName("div");
        for(i=0;i<4;i++)
        {
            i==value?divlist[i].style.display="block":divlist[i].style.display="none";
        }
    }

    
}
function cons(value){
    try
    {
        with (con)
        {
                for(i=0;i<4;i++)i==value?children[i].style.display="block":children[i].style.display="none";         
        }
    }
    catch(e)
    {
        var divlist = document.getElementById("con").getElementsByTagName("div");
        for(i=0;i<4;i++)
        {
            i==value?divlist[i].style.display="block":divlist[i].style.display="none";
        }        
    }
}

function clearAuto(){clearInterval(autoStart)}
function setAuto(){autoStart=setInterval("auto(n)", 5000)}
function auto(){
    n++;
    if(n>3)n=0;
    Mea(n);
}
function sub(){
    n--;
    if(n<0)n=3;
    Mea(n);
}
setAuto();

</script></td>
      </tr>
    </table></td>
    <td width="60%">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
</body>
</html>

[[it] 本帖最后由 绿柳红樱 于 2008-12-12 15:23 编辑 [/it]]
搜索更多相关主题的帖子: 脚本 
2008-12-11 17:57
绿柳红樱
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-9-10
收藏
得分:0 
帮我看看可以吗
2008-12-12 10:19
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
LZ你说的什么冲突啊???想实现什么样的效果?
这和多代码,看得眼睛花...

飘过~~
2008-12-12 14:30
快速回复:两个脚本出现冲突了,各位高手帮我看看怎么改?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035895 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved