IES: JS-deck 7 Flashcards
HTML confirm
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- displays dialog box & message, OK button, & Cancel button: often used to verify or accept something
- don’t overuse: prevents access to parts of page until closed
- Syntax
confirm(message)
- Example
~~~
let text;
if (confirm(“Press a button!”) == true) {
text = “You pressed OK!”;
} else {
text = “You canceled!”;
}
~~~
HTML constructor
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- creates and initializes an object instance of a class
- create a new object and set values for any existing object properties
- Syntax (JS)
constructor(parameters)
- Example (JS)
~~~
class Car {
constructor(brand) { // Constructor
this.carname = brand;
}
}
mycar = new Car(“Ford”);
~~~
HTML crypto
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- JavaScript is one of the primitive languages used in cryptocurrency blockchain development
- HTML is used in crypto coding specifically for the front end of decentralized applications (dApps) defining the structure of web pages
HTML decodeURI
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- (JS Global Method) decodes a URI
- Syntax
decodeURI(uri)
- Example
~~~
let uri = “my test.asp?name=ståle&car=saab”;
let encoded = encodeURI(uri);
let decoded = decodeURI(encoded);
~~~
(Decode a URI after encoding it)
HTML decodeURIcomponent
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- (JS Global Method) decodes a URI component
- Syntax
decodeURIComponent(uri)
- Example
~~~
let uri = “https://w3schools.com/my test.asp?name=ståle&car=saab”;
let encoded = encodeURIComponent(uri);
let decoded = decodeURIComponent(encoded);
~~~
(decode a URI after encoding it)
HTML defaultStatus
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- Deprecated: Remove to prevent RUN-TIME ERRORS in future
- Syntax
window.defaultStatus
- Example
window.defaultStatus = "Default text in the status bar!"
HTML document
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- File using HTML to structure & define web page content
- Example
~~~
<html>
<head>
<title>Href Attribute Example</title>
</head>
<body>
<h1>Href Attribute Example</h1>
<p>
<a>The freeCodeCamp Contribution Page</a> shows you how and where you can contribute to freeCodeCamp's community and growth.
</p>
</body>
</html>
~~~
HTML element
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- defined by a start tag, some content, and an end tag
- Empty elements have no content (<br></br>) and no end tag
- Syntax
Regular element<tagname>Content goes here...</tagname>
Empty element<tagname>attribute1 attribute2...<!--no content / end tag-->
- Example
~~~
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
<br></br>
<!--above-empty element; this comment code readers ignore-->
</body>
</html>
~~~
HTML elements
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- defined by a start tag, some content, and an end tag
- Empty elements have no content (<br></br>) and no end tag
- Syntax
Regular element<tagname>Content goes here...</tagname>
Empty element<tagname>attribute1 attribute2...<!--no content / end tag-->
- Example
~~~
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
<br></br>
<!--above-empty element; this comment code readers ignore-->
</body>
</html>
~~~
HTML embed
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- defines container for external resource, such as web page, picture, media player, or plug-in application
- WARNING: most browsers no longer support plugins
- Example
<embed type="image/jpg" src="pic_trulli.jpg" width="300" height="200">
(an embedded image)
HTML embeds
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- defines container for external resource, such as web page, picture, media player, or plug-in application
- WARNING: most browsers no longer support plugins
- Example
<embed type="image/jpg" src="pic_trulli.jpg" width="300" height="200">
(an embedded image)
HTML encodeURI
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- (JS Global Method) encodes a URI
- Syntax
encodeURI(uri)
- Example
~~~
let uri = “my test.asp?name=ståle&car=saab”;
let encoded = encodeURI(uri);
~~~
(encode a URI)
HTML encodeURIcomponent
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- (JS Global Method) encodes a URI component
- encodes special characters including: , / ? : @ & = + $ #
- Syntax
encodeURIComponent(uri)
- Example
~~~
let uri = “https://w3schools.com/my test.asp?name=ståle&car=saab”;
let encoded = encodeURIComponent(uri);
~~~
(encodes a URI)
HTML escape
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- aka- “HTML encoding” converts characters & symbols into HTML entity equivalents: Special characters, such as < and >, replace with corresponding HTML entities, such as
<
and>
.
HTML event
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- HTML can let events trigger actions in a browser, like starting a JS when an element is clicked.
- Example
Attribute:onerror
Value: script
Description: Script to be run when an error occurs