Technologies underlying the web Flashcards
What is syntax?
The structure of statements in a computer language.
Why is there a need to use JavaScript and CSS in the Web 2.0?
The Web 2.0’s content (constructed using HTML) has a style/layout (constructed using CSS) as well as a behaviour (controlled using JavaScript).
What does the basic structure of an HTML document include?
- Document type declaration
- HTML tags
- Head tags
- Title tags (usually included in head so it titles the whole window)
- Title of the page < h1 > < /h1 > (usually included in body)
- Body tags
- Paragraph tag < p > < /p > (usually included in body)
How do you include CSS (as a file) in an HTML document?
Included in the head using the following syntax:
< link rel=”stylesheet” type=”text/css” href=”theme.css” >
Note: “theme.css” refers to a hypothetical CSS file.
What kind of syntax could be included in a CSS file? (E.g. theme.css)
An example element could be:
h1 { color: green; } –> note the American spelling
How do you include JavaScript (as a file) in an HTML document?
Included in the body using the following syntax:
< script src=”my_script.js” > < / script >
How do you call a JavaScript function?
Identify the name of the function that was ‘called’/included in the HTML.
E.g. buttons can be specified in an HTML document using the following syntax:
< button type=”button” onclick=”myFunction()” >Date < / button >
In this case, you should state “myFunction();” in the JavaScript to call this function.
What kind of syntax is included in a JavaScript file? (E.g. my_script.js)
The file would include the following syntax: function myFunction() { document.getElementById("demo").innerHTML = Date(); }
Note: getElementById(“demo”) would refer to an element in the HTML with Id “demo” so for example,
< p id=”demo” > < / p >
What are some useful things you can do with JavaScript?
JavaScript aids in giving the user more control over the browser. It allows the creation of:
- pop up alerts
- interactive attribute change (e.g. turning the bulb on & off)
- drawing pictures
- interactive text creation (e.g. commenting on blogs)
- updating parts of the page without loading the entire page again (e.g. ASOS and quick view)
What are some things that should be considered when implementing JavaScript into an HTML document?
Different browsers may produce different results:
- JavaScript could be disabled by some end-users.
- Some commands only work in Internet Explorer and not other browsers.
- Versions of browsers matters.
What are variables?
- Must be declared by the word var (e.g. var age = 42;) Also, 42 refers to the value which has been assigned to the variable.
- An example variable: a name might be a variable which takes the value “Frank”. BUT “Frank” is not the same variable as Name.
What are some different types of variables?
- number
- string
- boolean
- object
- null
- undefined (nothing has been assigned)
- NaN (e.g. dividing by 0)
What are some examples of pre-defined functions in JavaScript?
- pop up alerts (window will appear with your message to the end user of the website)
- date (always gets current date)
How is a function defined in JavaScript?
- Need the keyword ‘function’ to start defining.
- A name for your choice for the function (e.g. showAge)
- Open and close parenthesis after function name ()
- Curly brackets {and} enclose all statements to execute as part of function.
- All statements should end with a semi-colon ;
Give an example of a defined function in JavaScript.
var age=42; function showAge() { alert("You are" + age); age= 65; }