JavaScript簡短匯總1

來源:互聯網
上載者:User

標籤:

JavaScript——指令碼語言 宿主檔案 NetScape  JSscript  JS 一、JavaScript基本文法。

(一)資料類型與變數類型。 資料類型:整數,小數,布局,字串,日期時間,數組

變數類型:var

強制轉換: parseInt() parseFloat()   isNaN()

parseint()用法    轉換輸入字串,變為int型。首字母不為數字,結果輸出nan(not a number);    

中間出現不為數位字元,該字元後的內容將不被解析,只顯示前面內容;      字串全為數字,全部顯示為int型。 parseFloat()用法同上。

isNaN()判斷是否為true。

(二)數組 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-6條會經常使用

1.alert()   沒有傳回值 window.alert();

2.[var a = ]window.confirm("你能跑過豹子嗎?");     //中括弧裡的內容沒有實際意義,只有判斷時才會用到 confirm()有傳回值true、false

 //prompt(); --不常用,不用記,輸入

3.open(); open("地址","_blank/_self","新視窗的特點"); [var a = ]window.open("http://www.sina.com.cn"); //中括弧內的內容沒有實際意義 在新視窗中開啟頁面,返回新的視窗。a也是一個window類型的變數。 詳細需要翻譯。網址:http://www.cnblogs.com/xianshui/p/4442699.html

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

 

5.setTimeout("code",毫秒數) 指定的毫秒數後,執行code一次。 function showTime() {  var date = new Date();  document.getElementById("hh").innerHTML = date;  window.setTimeout("showTime()",1000);   } window.setTimeout("showTime()",1000);

********開啟頁面,五秒後彈出廣告,再過5秒廣告關閉************ 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);

6.setInterval("code",毫秒數) 每隔指定的毫秒數就執行code一次。 // function showTime() {  var date = new Date();  document.getElementById("hh").innerHTML = date; } window.setInterval("showTime()",1000);

window.moveTo(x,y); window.resizeTo(width,height); window.scrollTo(x,y);

(二)曆史操作 window.history.go(n)

(三)地址欄操作 window.location.href //定時重新整理頁面 function showSelf() {  window.location.href="Untitled-3.html"; } window.setInterval("showSelf()",1000);

JavaScript簡短匯總1

聯繫我們

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