当前位置:网站首页>8、 BOM - chapter after class exercises and answers

8、 BOM - chapter after class exercises and answers

2022-06-11 21:28:00 Xiong xiansen's Treasure

Chapter 1 links : First time to know JavaScript - Chapter after class exercises and answers

Chapter II links :JavaScript Basics ( On ) - Chapter after class exercises and answers  

Chapter 3 links :JavaScript Basics ( Next ) - Chapter after class exercises and answers

Chapter 4 links :JavaScript function - Chapter after class exercises and answers

Chapter 5 links :JavaScript object - Chapter after class exercises and answers

Chapter 6 links :DOM( On ) - Chapter after class exercises and answers

Chapter 7 links :DOM( Next ) - Chapter after class exercises and answers

notes : It is published by the people's post and Telecommunications Publishing House 《JavaScript+jQuery Interactive Web The front-end development 》 Books .


  One 、 Completion

        1、  stay BOM in , The parent of all objects is ______.

        2、 The event triggered after all the contents in the page are loaded is ______.

        3、history Object's ______ Property to get... In the history list URL Number .

       4、 ______ Event is in DOM Triggered after the structure is loaded  .

Two 、 Judgment questions

        1、 Global variables can be accessed through window Object to access .(  )

        2、 modify location Object's href Property can be obtained or set URL.(  )

        3、 Use clearTimeout() and clearInterval() You can clear the timer .(  )

        4、 Use history Object's go() Method can realize page forward or backward .(  )

3、 ... and 、 choice question

        1、 In the following options , No window The properties of the object are (  ).

                A. pageX        B. location        C. history        D. navigator

        2、 The following about BOM Description of the object , The wrong is (  ).

                A. go(-1) And back() Both represent a step back from the history list

               B. adopt confirm() Realized “ confirm ” Dialog box , single click “ confirm ” When to return to true

               C. go(0) Refresh the current web page

                D. None of the above options are correct

        3、 The following description is wrong (  ).

                A. onload and DOMContentLoaded All are page loading events , There is no difference between

                B. DOMContentLoaded There is a browser compatibility problem

                C. The variables defined in the global scope are window Object properties

                D. window Object can be omitted when calling window

Four 、 Programming questions

         Programming , Realize the effect of automatic movement of electronic clock , A button is provided to control whether the electronic clock stops moving .


Refer to the answer :

One 、 Completion

        1、window              

        2、window.onload

        3、length

        4、document.DOMContentLoaded

Two 、 Judgment questions

        1、 Yes        2、 Yes      3、 Yes        4、 Yes

3、 ... and 、 choice question

        1、A        2、D        3、A 

Four 、 Programming questions

        Write functional code , The specific code is as follows :

<a id = "time"></a>
<button onclick = "clearInterval(time1)"> stop it </button>
<script type="text/javascript">
  var time1 = window.setInterval('timeShow()', 1000);
  timeShow()
  function timeShow() {
    var today = new Date(); // Get system current time 
    var intYears = today.getFullYear(); // Get year 
    intMonths = today.getMonth() + 1; // Get the month +1
    intDates = today.getDate(); // Get days 
    intHours = today.getHours(); // Get hours 
    intMinutes = today.getMinutes(); // Get minutes 
    intSeconds = today.getSeconds(); // Get seconds 
    intWeeks = today.getDay(); // Get week 
    //  Change the format to  * year * month * Japan 
    years = intYears + ' year ';
    //  If the month is less than 10, Add... Before the month 0
    intMonths < 10 ? months = '0' + intMonths + ' month ' : months = intMonths + ' month ';
    //  If the day is less than 10, Add in front of the day 0
    intDates < 10 ? dates = '0' + intDates + ' Japan ' : dates = intDates + ' Japan ';
    //  Modify week format 
    var week = [' Sunday ', ' Monday ', ' Tuesday ', ' Wednesday ', ' Thursday ', ' Friday ', ' Saturday ']
    weeks = week[intWeeks] + ' ';
    //  Modify the hour format 
    if (intHours == 0) {
      hours = '00:';
    } else if (intHours < 10) {
      hours = '0' + intHours + ':';
    } else {
      hours = intHours + ":";
    }
    //  Modify the minute format 
    if (intMinutes == 0) {
      minutes = '00';
    } else if (intMinutes < 10) {
      minutes = '0' + intMinutes;
    } else {
      minutes = intMinutes+ ":";
    }
    //   Modify the format of seconds 
    if (intSeconds == 0) {
      seconds = '00';
    } else if (intSeconds < 10) {
      seconds = '0' + intSeconds;
    } else {
      seconds = intSeconds;
    }
    var timeString = years + months + dates + weeks + hours + minutes+seconds
    document.getElementById('time').innerHTML = timeString;
  }
  </script>

   

原网站

版权声明
本文为[Xiong xiansen's Treasure]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206112122399880.html