JavaScript——指令碼語言

來源:互聯網
上載者:User

標籤:

一、JavaScript基本文法。

(一)資料類型與變數類型。 整數,小數,布局,字串,日期時間,數組 強制轉換: parseInt() parseFloat() isNaN()

(二)數組 var 數組名 = new Array([長度]); //“假冒”數組 a.length-長度 a[下標] = 值。 a[下標]

(三)函數

function 函數名(形參)

{

}

function ShowStr(a)

{

}

二、DOM操作
DOM - Document Object Model 文件物件模型。 樹
線狀模型,樹狀模型,網狀模型
window
 history
 location
 document

<html></html>
  head
  body
   a,img,table,ul,ol.....
 status

 

對象——object   特點的名詞 行為的動詞

(一)window 1.alert() window.alert();

2.[var a = ]window.confirm("你能跑過豹子嗎?");  //prompt(); --不常用,不用記,輸入

3.open(); open("地址","_blank/_self","新視窗的特點"); [var a = ]window.open("http://www.sina.com.cn"); 在新視窗中開啟頁面,返回新的視窗。a也是一個window類型的變數。 詳細需要翻譯。

4.close(); window.close();

5.setTimeout("code",毫秒數) 指定的毫秒數後,執行code一次。

舉例

<script language="javascript">function showTime(){    var date = new Date();    document.getElementById("hh").innerHTML = date;    window.setTimeout("showTime()",1000);    }window.setTimeout("showTime()",1000);</script>

練習
做一個5秒後出現新浪首頁的頁面

<script language="javascript">var a;function openAD(){    a = window.open("http://www.sina.com.cn","_blank","width=200 height=200 toolbar=no top=0 left=0");        window.setTimeout("closeAD()",5000);}function closeAD(){    a.close();}window.setTimeout("openAD()",5000);</script>

 

JavaScript——指令碼語言

聯繫我們

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