Summary of BOM Client Object Model

Keywords: Attribute

Window

  • Features: Get other BOM objects, location, history, document objects

  • Method

    1. Popup

      Alert (content); warning box

      confirm(); confirmation prompt box, used to make a prompt when the user exits or deletes the operation

      If the user clicks OK, return true

      If the user clicks Cancel, return false

    2. Open and Close Web Page Method

      open("New Window URL") Opens a new window and returns a value of window.

      close() closes the window

    3. timer

      setTimeout() one-time timer with a return value of a unique identifier to cancel the timer

      CleaTimeout (Unique Identification) Cancels One-Time Timer

      setInterval() loop timer with a return value of unique identifier to cancel the timer

      CleaInterval (Unique Identity) Cancel Loop Timer

location

  • Method

    reload() refresh page

  • attribute

    href Current Page URL Path

history

  • Method

    back() access the previous page

    forward() access the next page

    Go (parameter) accesses pages in history based on parameters

    !!! Note: Subhistory is the history of the current window, not the history of the browser!!!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>BOM</title>
</head>
<body>
    <img alt="picture" src="../img/banner_1.jpg" id="banner">
    <br>
    <input type="button" id="reload" value="Refresh">
    <br>
    <input type="button" id="forward" value="Forward">
    <br>
    <input type="button" id="back" value="Back off">
    <script>
        var num = 1;
        setInterval(fun,1000);
        function fun() {
            num++;
            if(num === 3)
            {
                num = 1;
            }
            //Gets the img element based on id and assigns the element address
            var image = document.getElementById("banner");
            image.src="../img/banner_"+num+".jpg";
        }
    </script>

    <script>
        //Warning box
        alert("I'm going to start acting!");
        //prompt box
        var bool = confirm("Are you sure you want to go?");
        if(bool)
        {
            window.close();
        }
        //Refresh button
        document.getElementById("reload").onclick = function(){
            location.reload();
        };
        var href = location.href;
        document.write(href);
        //Forward button
        document.getElementById("forward").onclick = function () {
            history.forward();
        };
        //back button
        document.getElementById("back").onclick = function () {
            history.back();
        };
    </script>
</body>
</html>

Posted by invarbrass on Mon, 07 Oct 2019 16:17:43 -0700