天天看點

JavaScript -基礎- 函數與對象(四) BOM 對象

一、bom對象

bom遊覽器對象模型,可以與遊覽器對話

bom下window對象最重要,還有history、location對象

二、window對象方法

1、alert提示框

2、confirm

confirm("hello")

JavaScript -基礎- 函數與對象(四) BOM 對象

用處:

檔案是對否儲存

下載下傳是否取消

var ret=confirm(“内容是否儲存!”)

alert(ret)   //傳回值是ture、false

if (ret){

}else{

}

3、prompt輸入框

var ret=prompr("hello")

alert(ret);  // 傳回值是輸入的參數,什麼都不輸入傳回空

JavaScript -基礎- 函數與對象(四) BOM 對象

4、定時器

三、history對象

前進、後退功能

history.forward(); 前進

history.back();     後退

history.go(1/-1);   //1表示前進、-1表示後退

四、location對象

定位

location.reload()                              重載/重新整理

location.href="www.baidu.com"       跳轉

繼續閱讀