一個網友寫的一些javascript指令碼,希望大家喜歡!

來源:互聯網
上載者:User
文章目錄
  • loadtwo.html
        移動圖片 遊戲

<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>
    下面是 點擊按鈕的同時在parentframe中,裝載兩個頁面
<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>
第 一 個 frame 會 載 入 loadtwo.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>
 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.