1. Explain the difference between the BOM (browser object model) and the DOM(document object model).
Browser Object Model
is the hierarchy of browser objects - the document object is a part of the hierarchy. The DOM is also managed by the BOM.Document Object Model
is the collection of HTML elements or Nodes that can be accessed or manipulated.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.
User Interface
: The browser interface that users interact with, includes everything except the requested page content (such as the address bar, bookmarks menu etc)Browser Engine
: Manages the interaction between the UI and the rendering engine.Rendering Engine
: Renders the requested page content. For example, if the requested content is HTML, the HTML and CSS will be parsed and rendered.Networking
: Handles all netword calls, for example HTTP requests.Javascript Interpreter
: Parses and executes our JS code.UI Backend
: Uses Operating System user interface methods.Data Storage
: Persistence of data stored in the browser, i.e. cookies.// 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).
global context
.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>
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.
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.