Objectives

Browser Basics

1. Explain the difference between the BOM (browser object model) and the DOM(document object model).

2. Given a diagram of all the different parts of the Browser identify each part. Use the Window API to change the innerHeight of a user’s window.

diagramBOM
diagramBOM
// First Open a new window
// Arguments are: URL, Name, ...Features
newWindow = window.open(
  "http://www.google.com",
  "Google",
  "width=100, height=100"
);
// Use resizeTo() Window API method to change the width & height
newWindow.resizeTo(500, 500);
// conducted in pixels

3. Identify the context of an anonymous functions running in the Browser (the window).

4. Given a JS file and an HTML file, use a script tag to import the JS file and execute the code therein when all the elements on the page load (using DOMContentLoaded)

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="someFile.js"></script>
  </head>
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->


<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->


</html>
window.addEventListener("DOMContentLoaded", (event) => {
  // some code
});

5. Given a JS file and an HTML file, use a script tag to import the JS file and execute the code therein when the page loads

<!DOCTYPE html>
<html>
  <head>
    <script async defer type="text/javascript" src="someFile.js"></script>
  </head>
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->


<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->


</html>

6. Identify three ways to prevent JS code from executing until an entire HTML page is loaded

7. Label a diagram on the Request/Response cycle.

RRdiagram
RRdiagram

8. Explain the Browser’s main role in the request/response cycle.

9. Given several detractors - identify which real-world situations could be implemented with the Web Storage API (shopping cart, forms saving inputs etc.)

10. Given a website to visit that depends on cookies (like Amazon), students should be able to go to that site add something to their cart and then delete that cookie using the Chrome Developer tools in order to empty their cart.