BOM以及幾個對象

JavaScript分爲三個部分

  • ECMAScript:JavaScript的語法標準。包括變量、表達式、運算符、函數、if語句、for語句等。javascript

  • DOM:文檔對象模型,操做網頁上的元素的API。好比讓盒子移動、變色、輪播圖等。html

  • BOM:瀏覽器對象模型,操做瀏覽器部分功能的API。好比讓瀏覽器自動滾動。 java

BOM:Browser Object Model,瀏覽器對象模型。瀏覽器

常見的幾個對象history location nabigator window函數

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <script>
        // open方法
        setTimeout(function () {
            // window對象打開窗口
            window.open('http://www.baidu.com', '_self');
        },2000);
        //location對象:至關於解析url
        setTimeout(function () {
            location.href = "http://www.baidu.com";
            window.location.reload();//重加載
        }, 5000);
        // navigator對象 能夠獲取客服端一些信息
        console.log(navigator.userAgent);
        console.log(navigator.platform);
    </script>
</body>
</html>

history對象
一、後退:url

  history.back()spa

  history.go(-1):0是刷新orm

二、前進:htm

  history.forward()對象

  history.go(1)

相關文章
相關標籤/搜索