Part 2 - Client side JavaScript and the DOM Flashcards
(98 cards)
gives access to all the images in a document.
describe the following
window.document.images
describe the following
window.location.pathname
will return the path of the current page
the javascript is:
document.getElementById("tt284").innerHTML = "<h2>Hello World</h2>"
write the javascript that will:
get the element with id “tt284” and then replace its nested content with a h2 header that says “hello world”
insert a javascript alert using an HTML script element
code:
<script> alert("JavaScript is working in your browser"); </script>
describe the
window.location
object
this is an object that has properties and methods that can display addrees, protocol and port information of the page and even redirect a page
give 2 benefits of a
thick client
Benefits:
* Operations no longer require a HTTP request to the server giving speed improvements and less waiting for the user
* Easier to deliver an application via a thick client than developing for different machines with different environments
describe the dom method
querySelectorAll()
Accesses all child elements matching a CSS selector
Accesses all child elements matching a CSS selector
describe the dom method
querySelectorAll()
this is a structure built by web browser from a given HTML document.
it is how the browser views and represent a page
what is the
document object model (DOM)
write the code that will import a javascript file
code:
<script src="path/to/file.js"></script>
what is the js code that
create a new HTML element and hold it inside a variable
the code is:var buttonElement = document.createElement("button");
converts a value to a number.
If the value cannot be converted,NaNis returned.
describe the javascript method
number()
give two drawbacks of javascripts
innerHTML
drawbacks include:
1.Screen readers may not be aware of the new content
2.Care must be taken when adding untrusted data in case it is malicious
these include:
1. Ad blockers - used to block ads
2. Reference management tools - which help collect and mange reference material for research
3. Bookmarking - allowing users to collect and annotate content
give 3 examples of adding functionality to a web browser
describe the following
window.document.forms
gives access to all the forms in a document.
describe the javascript method
toFixed()
method converts a number to a string and rounds the string to a specified number of decimals.
describe the
window.navigator
object
this is an object that will hold details of the users browser
software will use these so that they can access, read and modify there nodes
this means that dynamic content can be created
how does software take advantage of the:
Document Object Model (DOM)
and
Browser Object Model (BOM)
Accesses all child elements with a specified tagname
describe the dom method
getElementsByTagName()
describe the following
window.document.characterSet
this will access and return the character encoding for the document
this object contains the browsers history
describe the
window.history
object
code:
<script> alert("JavaScript is working in your browser"); </script>
insert a javascript alert using an HTML script element
this is similar to the Document Object Model (DOM) in that it is a structure that is built by the browser.
however this will instead expose parts of the web browser instead of the HTML document
what is the
Browser Object Model (BOM)
drawbacks include:
1.Screen readers may not be aware of the new content
2.Care must be taken when adding untrusted data in case it is malicious
give two drawbacks of javascripts
innerHTML