JavaScript學習——BOM對象

來源:互聯網
上載者:User

標籤:跳轉   click   html   int   logs   刪除   使用者   技術   bom   

1、BOM 對象:瀏覽器物件模型(操作與瀏覽器相關的內容) 

2、Window 對象 

 Window 對象表示瀏覽器中開啟的視窗

setInterval():它有一個傳回值,主要是提供給 clearInterval 使用

setTimeout():它有一個傳回值,主要是提供給 clearTimeout 使用

clearInterval():該方法只能清除由 setInterval 設定的定時操作

clearTimeout():該方法只能清除由 setTimeout 設定的定時操作 

彈出框的幾個方法:

 1 <!DOCTYPE html> 2 <html> 3     <head> 4         <meta charset="UTF-8"> 5         <title>Window對象</title> 6         <script> 7             //警告框 8             alert("啊哈!"); 9             //確認刪除框10             confirm("您確認刪除嗎?");11             //輸入框12             prompt("請輸入價格");13         </script>14     </head>15     <body>16     </body>17 </html>

3、History對象

 History 對象包含使用者(在瀏覽器視窗中)訪問過的 URL

執行這段代碼之前要有曆史頁面,可以是超連結跳轉到此頁面。

 1 <!DOCTYPE html> 2 <html> 3     <head> 4         <meta charset="UTF-8"> 5         <title>History對象</title> 6         <script> 7             function fanhui(){ 8                 history.go(-1); 9                 //history.back();10             }11         </script>12     </head>13     <body>14         <input type="button" value="返回上一頁" onclick="fanhui()" />15     </body>16 </html>

go(參數)  

參數:-1 返回上一個記錄頁面;-2 返回上上一個記錄頁面,1 進入下一個記錄頁面。

3、Location對象

 Location 對象包含有關當前 URL 的資訊。 

 1 <!DOCTYPE html> 2 <html> 3     <head> 4         <meta charset="UTF-8"> 5         <title>Location對象</title> 6     </head> 7     <body> 8         <input type="button"  value="跳轉到History頁面" onclick="javascript:location.href=‘02_History對象.html‘"/> 9     </body>10 </html>

 

JavaScript學習——BOM對象

聯繫我們

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