您的位置:首页 > Web前端 > JavaScript

一个网友写的一些javascript脚本,希望大家喜欢!(转载)

2005-12-08 11:10 681 查看
       
<html>
<head>
<title></title>
<script language="javascript">
var b2=3; b1=6; a2=4; a1=2;
function moveIt()        {bbb.style.left=parseInt(bbb.style.left)-b1;         bbb.style.top=parseInt(bbb.style.top)+b2;         aaa.style.left=parseInt(aaa.style.left)+a1;         aaa.style.top=parseInt(aaa.style.top)+a2;         if
((parseInt(bbb.style.left)<-50)||(parseInt(bbb.style.left)>860))            {b1=-b1;}         if ((parseInt(bbb.style.top)<-15)||(parseInt(bbb.style.top)>490))            {b2=-b2;}         if ((parseInt(aaa.style.left)<0)||(parseInt(aaa.style.left)>800))            {a1=-a1;}         if ((parseInt(aaa.style.top)<-100)||(parseInt(aaa.style.top)>450))            {a2=-a2;}         setTimeout('moveIt()',100);         }
</script>
</head>
<body onload="moveIt()">
<div id="bbb" style="position:relative; left:20px; top:8px; width:40px;
height:16px;">
<dd><img src="book.gif" width="128" height="128"></dd>
</div>
<div id="aaa" style="position:relative; left:100px; top:8px; width:9000px;
height:16px;">
<dd><font color="#ff00ff">It'a very good!</font>
</div>
</body>
<html>  一个js的树形结构脚本

<script language="JavaScript">
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;
 
if (ver4) {    with (document) {        write("<STYLE TYPE='text/css'>");        if (NS4) {            write(".parent {position:absolute; visibility:visible}");            write(".child {position:absolute; visibility:visible}");            write(".regular {position:absolute; visibility:visible}")        }        else {            write(".child {display:none}")        }        write("</STYLE>");    }
}
 
function getIndex(el) {    ind = null;    for (i=0; i<document.layers.length; i++) {        whichEl = document.layers;        if (whichEl.id == el) {            ind = i;            break;        }    }    return ind;
}
 
function arrange() {    nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;    for (i=firstInd+1; i<document.layers.length; i++) {        whichEl = document.layers;        if (whichEl.visibility != "hide") {            whichEl.pageY = nextY;            nextY += whichEl.document.height;        }    }
}
 
function initIt(){    if (!ver4) return;    if (NS4) {        for (i=0; i<document.layers.length; i++) {            whichEl = document.layers;            if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";       }        arrange();    }    else {        divColl = document.all.tags("DIV");        for (i=0; i<divColl.length; i++) {            whichEl = divColl(i);            if (whichEl.className == "child") whichEl.style.display = "none";        }    }
}
 
function expandIt(el) {    if (!ver4) return;    if (IE4) {        whichEl = eval(el + "Child");        if (whichEl.style.display == "none") {            whichEl.style.display = "block";        }        else {            whichEl.style.display = "none";        }    }    else {        whichEl = eval("document." + el + "Child");        if (whichEl.visibility == "hide") {            whichEl.visibility = "show";        }        else {            whichEl.visibility = "hide";        }        arrange();    }
}
onload = initIt;
</script>        </font></p>      <div id="KB1Parent" class="parent">    <a href="#" onClick="expandIt('KB1'); return false" ><img src="img/plus.gif" border=0>文件夹一</a></div>      <div id="KB1Child" class="child">     <a href="sample.htm" target="_blank" ><img src="img/spacer.gif"  border=0 alt=""><img src="img/open.gif"  border=0>页面一</a><br>             <a href="sample.htm" target="_blank" ><img src="img/spacer.gif"  border=0 alt="" width="15" height="11"><img src="img/open.gif"  border=0>页面二</a><br>             <a href="sample.htm" target="_blank" ><img src="img/spacer.gif"  border=0 alt="" width="15" height="11"><img src="img/open.gif"  border=0>页面三</a></div>      <div id="KB2Parent" class="parent">    <a href="#" onClick="expandIt('KB2'); return false" ><img src="img/plus.gif" border=0>文件夹二</a></div>      <div id="KB2Child" class="child">     <a href="sample.htm" target="_blank" ><img src="img/spacer.gif"  border=0 alt="" width="15" height="11"><img src="img/open.gif"  border=0>页面一</a><br>             <a href="sample.htm" target="_blank" ><img src="img/spacer.gif"  border=0 alt=""><img src="img/open.gif"  border=0>页面二</a><br>             <a href="sample.htm" target="_blank" ><img src="img/spacer.gif"  border=0 alt="" width="15" height="11"><img src="img/open.gif"  border=0>页面三</a></div>      <div id="KB3Parent" class="parent">    <a href="#" onClick="expandIt('KB3'); return false" ><img src="img/plus.gif"  border=0>文件夹三</a></div>      <div id="KB3Child" class="child">      <a href="sample.htm" target="_blank" ><img src="img/spacer.gif"  border=0 alt=""><img src="img/open.gif"  border=0>页面一</a><br>              <a href="sample.htm" target="_blank" ><img src="img/open.gif"  border=0>页面二</a><br>             <a href="sample.htm" target="_blank" ><img src="img/spacer.gif"  border=0 alt=""><img src="img/open.gif"  border=0>页面三</a></div>      <script language="JavaScript">
if (NS4) {        firstEl = "KB1Parent";        firstInd = getIndex(firstEl);        arrange();
}
</script>
<HTML>
<HEAD>
<title>Frames</title>
</HEAD>
<FRAMESET COLS="295,*">
<FRAMESET ROWS="100%,*">
<FRAME SRC="loadtwo.html" NAME="fr1">
</FRAMESET>
<FRAMESET ROWS="75%,25%">
<FRAME SRC="cell.html" NAME="fr2">
<FRAME SRC="cell.html" NAME="fr3">
</FRAMESET>
</FRAMESET>
</HTML>

loadtwo.html

<HTML>
<HEAD>
<script language="JavaScript">
<!-- Hiding
function loadtwo(page2, page3) {
parent.fr2.location.href=page2;
parent.fr3.location.href=page3;
}
// -->
</script>
</HEAD>
<BODY>
<FORM NAME="buttons">
<INPUT TYPE="button" VALUE="同 时 载 入 两 份 文 件" onClick="loadtwo('frtest1.html',
'frtest2.html')">
</FORM>
</BODY>
</HTML>
<html> <body> <input type=button name =b1 value="按钮1" onclick="abc()"> <input type=button name =b2 value="按钮2" > <input type=button name =b3 value="按钮3"> </body>
</html>
<script language=javascript>
function abc()
{ for(i=1;i<=3;i++) {  document.all("b"+i).value=i; }
}
</script>
图片移动标签:
scrollAmount=2   数字越大,速度越快
direction=up  移动的方向  可以变换英文“下”“左”“右”

height=200   为移动的高度  
<MARQUEE scrollAmount=2 direction=up height=200>  <P align=center><IMG src="C:/Documents and Settings/Administrator/My Documents/My Pictures/haha1.gif"></P>  欢迎光临!!!
</marquee>
<MARQUEE scrollAmount=2 direction=right height=200>  <P align=center><IMG src="C:/Documents and Settings/Administrator/My Documents/My Pictures/haha1.gif"></P>  欢迎光临!!!
</marquee>

 
 
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐