IES: JS-deck 9 Flashcards
1
Q
HTML outerWidth
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- property returns outer width of browser window, including all interface elements (like toolbars/scrollbars)
- read only
- Syntax
window.outerWidth
orouterWidth
- Return Value
Browser window width, all interface elements, in pixels
2
Q
HTML packages
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- In web development context, collection of HTML files, often grouped with related assets like CSS and JavaScript
- easily imported or reusable component in a larger website
- Acting as pre-built module with specific functionality/design
- Example
Product card package:
1.product-card.html
: card structure & image, title, price, etc. placeholders
2.product-card-styles.css
: card styles (layout, colors, fonts)
3
Q
HTML pageXOffset
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- read-only property: equal to
scrollX
- returns pixels doc scrolled from upper left window corner
Syntaxwindow.pageXOffset
orpageXOffset
Example
window.scrollBy(100, 100); alert(window.pageXOffset + window.pageYOffset); (scrolls the content by 100 pixels, and alerts the pageXOffset and pageYOffset)
4
Q
HTML pageYOffset
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- read-only property: equal to
scrollY
- returns pixels doc scrolled from upper left window corner
- Syntax
1.window.pageYOffset
or
2.pageYOffset
- Example
// Get the navbar const navbar = document.getElementById("navbar"); // Get the offset position of the navbar const sticky = navbar.offsetTop; // Add the sticky class to the navbar when you reach its scroll position. Remove the sticky class when you leave the scroll position. function myFunction() { if (window.pageYOffset >= sticky) { navbar.classList.add("sticky") } else { navbar.classList.remove("sticky"); } }
(Create a sticky navigation bar)
5
Q
HTML parent
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- parent is the element which contains another element
- children are the contained elements.
- A child element can also have nested elements inside it, making it a parent element to its nested elements.
- Very often children behavior/appearance influenced by their parent settings.
6
Q
HTML parseFloat
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- method parses a value as a string and returns first number
- first character can’t convert,
NaN
returned - Only first number found returned
- Syntax
parseFloat(value)
- Example
parseFloat("40.00"); parseFloat(" 40 "); parseFloat("40 years"); parseFloat("40H") parseFloat("H40");
(Parse different values)
7
Q
HTML parseInt
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- method parses a value as a string & returns first integer
- A radix parameter specifies number system:
2 = binary, 8 = octal, 10 = decimal, 16 = hexadecimal. - radix is omitted, JS assumes radix 10: value begins “0x”, ONJS assumes radix 16.
- Older JS versions used octal (radix 8) values begin with “0”: From JS5 (2009), default is decimal (radix 10).
- first character can’t convert, NaN is returned
- Leading & and trailing spaces ignored.
- Only first integer found returned.
8
Q
HTML password
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
-
<input>
type attribute: defines a password field - sensitive info should always be served over HTTPS
- always add
<label>
for best accessibility practices - Syntax
<input type="password">
- Example
<label for="pwd">Password:</label> <input type="password" id="pwd" name="pwd">
9
Q
HTML pkcs11
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- Cryptography: secure info & comm techniques derived from algorithms to transform messages in ways hard to decipher
- cryptographic token interface standard that defines an API, called Cryptoki, for accessing cryptographic devices
- represents cryptographic devices using tokens (digital representations of interest (percent of ownership) in an asset): Any device or token can perform cryptographic operations using same independent command set.
10
Q
HTML plugin
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- computer programs extending standard browser function
- MOST BROWSERS DON’T BEAR JAVA APPLETS & PLUG-INS
11
Q
HTML prompt
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- method displaying dialog box prompting for input
- returns input value if “OK” clicked, otherwise returns null
- Syntax
prompt(text, defaultText)
- Example
let text; let favDrink = prompt("What's your favorite cocktail drink?"); switch(favDrink) { case "Coca-Cola": text = "Excellent choice! Coca-Cola is good for your soul."; break; case "Pepsi": text = "Pepsi is my favorite too!"; break; case "Sprite": text = "Really? Are you sure the Sprite is your favorite?"; break; default: text = "I have never heard of that one!"; }
12
Q
HTML propertyIsEnum
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- (C, C++, C#, Java) special type of constants (unchangeable values)
- create enum: use enum keyword, followed by enum name
- enum has attributes and methods
- (couldn’t find “propertyIsEnum”)
- Example
enum Months { January, // 0 February, // 1 March, // 2 April, // 3 May, // 4 June, // 5 July // 6 } static void Main(string[] args) { int myNum = (int) Months.April; Console.WriteLine(myNum); }
- (Output is 3)
13
Q
HTML radio
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
-
<input type="radio">
defines a radio button. - normally presented in groups (related set options)
- Only one in a group can be selected at the same time.
- must share same name attribute to be treated as group
- selecting any button auto deselects any other in same group
- have as many groups: each page group must have own name
- Always add the
<label>
tag for best accessibility practices! - Syntax
<input type="radio">
- Example
<input type="radio" id="html" name="fav_language" value="HTML"> <label for="html">HTML</label><br> <input type="radio" id="css" name="fav_language" value="CSS"> <label for="css">CSS</label><br> <input type="radio" id="javascript" name="fav_language" value="JavaScript"> <label for="javascript">JavaScript</label>
- (Allow selection of only one of limited number of choices)
14
Q
HTML reset
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
-
<input type="reset">
: resets form values to initial values - Syntax
<input type="reset">
- Example
<input type="reset">
- (Defines a reset button)
15
Q
HTML screenX
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- property returns x (horizontal) window coordinate relative to screen (in pixels)
- Syntax
window.screenX
orscreenX
- Example
const myWin = window.open("", "", "width=200,height=100"); let x = myWin.screenX; let y = myWin.screenY;
- (Opens new window; returns coordinates)
16
Q
HTML screenY
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- property returns y (vertical) window coordinate relative to screen (in pixels)
- Syntax
window.screenY
orscreenY
- Example
const myWin = window.open("", "", "left=700,top=350,width=200,height=100"); let x = myWin.screenX; let y = myWin.screenY;
- (Opens new window with specified left & top position; & returns coordinates)
17
Q
HTML scroll
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- (CSS)
scroll-behavior
property specifies manner of animation when link clicked within scrollable box - Property values:
1. auto - (default) allows straight jump between tags in scrolling box
2. smooth- Allows smooth animated “scroll effect” between elements within the scrolling box.
3. initial- Sets this property to its default value
4. inherit- obtains property from parent settings - Syntax
scroll-behavior: auto|smooth|initial|inherit;
- Example
html { scroll-behavior: smooth; }
- (Add smooth scrolling to doc)
18
Q
HTML secure
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- The term HTML security or secure HTML refers to one of two areas: protecting HTML code and content from piracy and misuse.
19
Q
HTML select
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- used to create a drop-down list: used most often in a form, to collect user input
- Always add the
<label>
for best accessibility practices! - Example
<label for="cars">Choose a car:</label> <select name="cars" id="cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select>
- (Creates a drop-down list with four options)
20
Q
HTML self
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- HTML self can refer to a self-closing tag which is an empty tag and has no closing tag
- HTML self can also refer to a target attribute value for the anchor tag
<a>
:_self
, which opens the linked document in the same frame as it was clicked and is the default value for that target attribute for anchor - Syntax:
<a target="_blank|_self|_parent|_top|framename">
- Example
<a href="https://www.w3schools.com" target="_blank">Visit W3Schools</a>
- (target attribute specifies where to open linked doc)