JavaScript,javascript教程

來源:互聯網
上載者:User

JavaScript,javascript教程
JavaScript基本結構

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">    <head>        <title>JavaScript基本結構</title>        <meta http-equiv="keywords" content="enter,your,keywords,here" />        <meta http-equiv="description" content="A short description of this page." />        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />        <script type="text/javascript" src="js/hello.js"></script>        <script type="text/javascript">            //alert("Hello JavaScript !");            //document.writeln("Hello JavaScript !");            var num1;            num1=25;            var num2=13;            var Num1=250; //JavaScript區分大小寫            //alert(num1+","+num2+","+Num1);            var flag=true;            var height=180.5;            var name="tom";            hobby="game";            var num3;            var num4=null;            var today=new Date();            var nums=new Array(13,25,250);            //alert(hobby);            /*alert(typeof(num1));            alert(typeof(flag));            alert(typeof(height));            alert(typeof(name));            alert(typeof(num3));            alert(typeof(num4));            alert(typeof(today));            alert(typeof(nums)); */            //switch選擇結構            var weekday="星期日";            switch(weekday){                case "星期一":                    alert("新的一周又開始了,上墳一樣的心情!");                    break;                case "星期二":                 case "星期三":                 case "星期四":                    alert("好好工作,好好學習");                    break;                case "星期五":                    alert("明天就放假了");                    break;                default:                    alert("睡到自然醒!");                    break;                      }            //定義一個數組            var names=new Array("tom","alice","mike","jone sun");            //alert(names[2]);            //alert(names.length);            names.sort();            names.reverse();            for(var i=0;i<names.length;i++){                document.writeln(names[i]);            }            document.writeln("<br/>");            //foreach迴圈            for(var i in names){                document.writeln(names[i]);            }            var username=prompt("請輸入您的姓名:","");            alert(username);        </script>    </head>    <body>        <p>            This is my XHTML page.        </p>        <input type="button" value="點我" onclick="alert('我是被點了才出來的')" /><br/>        <a href="javascript:alert('嘿嘿')">嘿嘿</a>    </body></html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.