不就是蓝白胖次吗吧 关注:8贴子:789
  • 10回复贴,共1

【考试复习】JavaScript代码

只看楼主收藏回复

只是为了明天上课能偷偷背代码做的备份


1楼2014-12-02 06:04回复
    PROGETTO1:Alert
    <html>
    <head>
    <meta charset="utf-8" />
    <title>Avviso</title>
    <SCRIPT language="javascript">
    function mostraMessaggio(){
    alert("Salve! Benvenuto nel nostro sito");}
    </SCRIPT>
    </head>
    <body>
    <INPUT TYPE="button" VALUE="Prova" NAME="B1" onClick="mostraMessaggio()" />
    </body>
    </html>


    2楼2014-12-02 06:06
    回复
      PROGETTO1BIS:Alert(“ ” + “ ”)
      <html>
      <head>
      <meta charset="utf-8"/>
      <title>Avvio</title>
      <SCRIPT language="javascript">
      var nome
      function prompter(){
      alert("Salve " + nome + "!")}
      </SCRIPT>
      </head>
      <body onLoad="nome=prompt('Inserisci il nome');">
      <INPUT TYPE="button" VALUE="PROVA" NAME="B1" onClick="prompter()"/>
      </body>
      </html>


      3楼2014-12-02 06:08
      回复
        PROGETTO1BISBIS:Alert(" " + " ") + condizione IF + href
        <html>
        <head>
        <meta charset="utf-8"/>
        <title>Avvio</title>
        <SCRIPT language="javascript">
        var nome
        function mostraMessaggio(){
        alert("Salve " + nome + "!Questa è la tua pagina di prova in 'JavaScript' ");
        var messaggio = 'Vuoi aprire la pagina di GOOGLE?';
        var conferma = confirm(messaggio);
        if(conferma == true)
        self.location.href = 'https://www.google.com/?hl=it&gws_rd=ssl'
        else
        alert("Hai selezionato il pulsante ANNULLA!");
        }
        </SCRIPT>
        </head>
        <body onLoad="nome=prompt('Inserisci il nome');">
        <INPUT TYPE="button" VALUE="PROVA" NAME="B1" onClick="mostraMessaggio();" a href="https://www.google.com/?hl=it&gws_rd=ssl" />
        </body>
        </html>


        4楼2014-12-02 06:11
        回复
          PROGETTO2:OnMouseOver + OnMouseOut
          <html>
          <head>
          <meta charset="utf-8" />
          <title>Il mio PC</title>
          <script language="javascript">
          function scriviTesto(testo){
          document.getElementById("descrizione").innerHTML=testo;
          }
          function ritorna(testo){
          document.getElementById("descrizione").innerHTML=testo;
          }
          </script>
          </head>
          <body>
          <div align="center">
          <img src="pc2.gif" width="450" height="330" usemap="#PCmap"/>
          <map name="PCmap">
          <area shape="rect" coords="94,1,326,161"
          onMouseOver="scriviTesto('Monitor. Dispositivo di output che permette di visualizzare immagini e video.')"
          href="http://it.wikipedia.org/wiki/Monitor_video"
          onMouseOut="ritorna('Sposta il mouse sull\'\immagine per visualizzare le informazioni. Se fai click troverai le informazioni di Wikipedia.')">
          <area shape="rect" coords="47,253,384,291"
          onMouseOver="scriviTesto('Tastiera. Dispositivo di imput che permette di inserire testo.')"
          href="http://it.wikipedia.org/wiki/Tastiera_(informatica)"
          onMouseOut="ritorna('Sposta il mouse sull\'\immagine per visualizzare le informazioni. Se fai click troverai le informazioni di Wikipedia.')">
          <area shape="rect" coords="312,291,395,331"
          onMouseOver="scriviTesto('Mouse. Dispositivo di input che permette di sposare un cursore sullo schermo.')"
          href="http://it.wikipedia.org/wiki/Mouse"
          onMouseOut="ritorna('Sposta il mouse sull\'\immagine per visualizzare le informazioni. Se fai click troverai le informazioni di Wikipedia.')">
          <area shape="rect" coords="75,191,354,254"
          onMouseOver="scriviTesto('Case. Dispositivo di output che permette di visualizzare immagini e video.')"
          href="http://it.wikipedia.org/wiki/Case_(hardware)"
          onMouseOut="ritorna('Sposta il mouse sull\'\immagine per visualizzare le informazioni. Se fai click troverai le informazioni di Wikipedia.')">
          </map>
          <P ID="descrizione">Sposta il mouse sull'immagine per visualizzare le informazioni. Se fai click troverai le informazioni di Wikipedia.</P>
          </div>
          </body>
          </html>


          5楼2014-12-02 06:12
          回复
            PROGETTO2BIS:Cambio Immagine(OnMouseOn + OnMouseOut)
            <html>
            <head>
            <meta charset="utf-8" />
            <title>Cambio Immagine</title>
            <script language="javascript">
            function Immagine(img){
            document.getElementById("descrizione").innerHTML=testo;
            }
            </script>
            </head>
            <body>
            <div align="center">
            <h1 P ID="descrizione">CAMBIO IMMAGINE</P>
            <img src="pc.gif" onMouseOver="this.src='pc2.jpg'" "WIDTH="431" HEIGHT="383" onMouseOut="this.src='pc.gif'"/>
            </div>
            </body>
            </html>


            6楼2014-12-02 06:13
            回复
              PROGETTO3:Table + Calcola Montante
              <html>
              <head>
              <title>Interesse composto</title>
              <script language="javascript">
              function calcola(form){
              tassoUnit = form.tasso.value / 100;
              montante = form.capitale.value * Math.pow((1 + tassoUnit),form.tempo.value);
              form.montante.value = Math.round(montante*100)/100;
              form.interesse.value = Math.round((montante - form.capitale.value)*100)/100;
              }
              </script>
              <style type="text/css">
              TD{
              text-align: center;
              }
              </style>
              </head>
              <body>
              <H2 align="center">Calcolo dell'Interesse Composto</H2>
              <FORM>
              <TABLE border="0" align="center">
              <tr><td>Capitale iniziale</td>
              <td><b>C</b></td>
              <td><input type="Text" NAME="capitale" size="10"></td>
              <td>&euro;</td></tr>
              <tr><td>Tasso di interesse</td>
              <td><b>i</b></td>
              <td><input type="Text" NAME="tasso" SIZE="10">
              </td><td>%</td></tr>
              <tr><td>Tempo</td>
              <td><b>t</b></td>
              <td><input type="Text" NAME="tempo" SIZE="10">
              </td><td>anni</td></tr>
              <tr><td colspan="3">
              <input type="button" VALUE="Calcola tasso" NAME="Invia"
              OnClick ="calcola(this.form)">
              <input type="reset" VALUE="Annulla" NAME="Rifare">
              </td></tr>
              <tr><td>Interesse</td>
              <td><b>I</b></td>
              <td><input type="Text" name="interesse" size="10"></td>
              <td>&euro;</td></tr>
              <tr><td>Montante</td>
              <td><b>M</b></td>
              <td><input type="Text" NAME="montante" SIZE="10"></td>
              <td></td></tr>
              </table>
              </form>
              </body>
              </html>


              7楼2014-12-02 06:15
              回复
                PROGETTO5:document.GetElementById("display")/("Id") + Eval +
                <html>
                <head>
                <script language="javascript" src="calcola.js">
                </script>
                </head>
                <title>Calcolatrice</title>
                <body>
                <table align="center" cellpadding="0" cellspacing="0">
                <tr>
                <td height="40" colspan="4" align="right">
                <input type="text" id="display" style="width:80px; height:20px;" />
                </td>
                </tr>
                <tr>
                <td><input type="button" value="7" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=7" /></td>
                <td><input type="button" value="8" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=8" /></td>
                <td><input type="button" value="9" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=9" /></td>
                <td><input type="button" value="/" style="width:20px; height:20px;"
                onclick="diviso()"></td>
                </tr>
                <tr>
                <td><input type="button" value="4" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=4" /></td>
                <td><input type="button" value="5" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=5" /></td>
                <td><input type="button" value="6" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=6" /></td>
                <td><input type="button" value="x" style="width:20px; height:20px;"
                onclick="per()"></td>
                </tr>
                <tr>
                <td><input type="button" value="1" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=1" /></td>
                <td><input type="button" value="2" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=2" /></td>
                <td><input type="button" value="3" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=3" /></td>
                <td><input type="button" value="-" style="width:20px; height:20px;"
                onclick="meno()"></td>
                </tr>
                <tr>
                <td><input type="button" value="0" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=0" /></td>
                <td><input type="button" value="C" style="width:20px; height:20px;"
                onclick="document.getElementById('display').value+=' '; val1=0 :"/></td>
                <td><input type="button" value="=" style="width:20px; height:20px;"
                onclick="uguale()"></td>
                <td><input type="button" value="+" style="width:20px; height:20px;"
                onclick="piu()"></td>
                </tr>
                </table>
                </head>
                </html>
                附件:calcola.js
                function piu(){
                val1 = eval(document.getElementById("display").value);
                op="piu";
                document.getElementById('display').value=' ';
                }
                function meno(){
                val1 = eval(document.getElementById("display").value);
                op="meno";
                document.getElementById('display').value=' ';
                }
                function per(){
                val1=eval(document.getElementById("display").value);
                op="per";
                document.getElementById('display').value=' ';
                }
                function diviso(){
                val1=eval(document.getElementById("display").value);
                op="diviso";
                document.getElementById('display').value=' ';
                }
                function uguale(){
                val2=eval(document.getElementById("display").value);
                switch(op){
                case "diviso":
                risultato = val1 / val2;
                break;
                case "per":
                risultato = val1 * val2
                break;
                case "piu":
                risultato = val1 + val2
                break;
                case "meno":
                risultato = val1 - val2;
                break;
                default:
                risultato = "errore";
                }
                document.getElementById('display').value = risultato
                }


                8楼2014-12-02 06:19
                回复
                  卧槽考试推到下星期了!!!!!:班长gj!!!


                  来自Android客户端9楼2014-12-02 17:24
                  回复











                    来自Android客户端10楼2014-12-09 17:16
                    回复










                      来自Android客户端11楼2014-12-09 17:17
                      回复