Tutorials 7, 10-13 2nd Most Likely
Provide the HTML code to insert the royal.mp3 file using the embed element. Display controls for the embedded object and have it start automatically when the page loads, beginning 5 seconds into the clip.
<embed src="royal.mp3" type="audio/mpeg" autoplay="true" starttime="00:00:05" />
Provide the HTML code to play the audio clip soundtrack.mp3 as a background sound that plays continuously when the page is opened by a browser.
<audio controls="controls" autoplay="autoplay" loop="loop"> <source src="soundtrack.mp3" /> </audio>
Provide the code to embed the file trailer.swf as a Web page object. Set the dimensions of the Flash player to 350 pixels wide by 150 pixels high.
<object data="trailer.swf" type="application/x-shockwave-flash" width="350" height="150"> <param name="movie" value="trailer.swf" /> </object>
What is a program loop? Name three types of program loops supported by JavaScript.
A program loop is a set of commands that is executed repeatedly until a stopping condition has been met. Three program loops supported by JavaScript are the For, While, and Do/While loops.
Provide code to round the value of the thisMonth variable to the nearest integer.
Math.round(thisMonth)
What is a container file? Which three container file formats are currently supported under HTML5 video?
The container file is the file that stores the codec. Four container file formats are Flash Video, MP4, Ogg Theora, and WebM.
What code would you enter to display the value of the userName variable in an alert dialog box?
alert(userName);
What is the MIME type for a WAV file?
audio/wav
What command can be used to break out of the current iteration in a for loop?
break;
What command creates a variable named currentTime that stores the current date and time?
currentTime = new Date();
Provide a command to extract the middle five values from the dayNames array.
dayNames.slice(1,6);
Provide a command to return the third value from the dayNames array.
dayNames[2]
An element from a Web document has the id attribute value topButtons. Provide an expression referencing this object.
document.getElementById("topButtons")
Specify the JavaScript command to write the code <img src='file' alt='' /> to a Web page, where file is the value stored in the fileName variable.
document.write("<img src=′" + fileName + "′ alt=′′ />");
Provide a for statement that creates a table row consisting of five table cells. Assume the table cells display the text Column i, where i is the value of the counter variable, and the value of the counter variable increases from 1 to 5 in increments of 1.
document.write("<tr>"); for (var i = 1; i <= 5; i++) { document.write("<td>Column " + i + "</td>") } document.write("</tr>");
What JavaScript command would you enter to write the following tag to a Web document? <h2 id="sub">Public Library</h2>
document.write(′<h2 id="sub">Public Library</h2>′);
What command extracts the four-digit year value from the examDate variable?
examDate.getFullYear()
What code writes the text Internet Explorer Browser to the document if the Boolean variable WebBrowser equals true?
if (WebBrowser) document.write("Internet Explorer Browser"); or if (WebBrowser == true) document.write("Internet Explorer Browser");
What are the three types of errors generated by mistakes in a JavaScript program?
load-time error, run-time error, and logical error
What statement runs the function calcMonth() every 0.5 seconds?
setInterval("calcMonth", 500);
Create an object collection named allParagraphs to match every paragraph in the Web document, and then provide the code to remove all inline font-size styles from every object in that collection.
var allParagraphs = document.getElementsByTagName("p"); for (var i = 0; i < allParagraphs.length; i++) { allParagraphs[i].style.fontSize = ""; }
The first article element in a document has its width in pixels set with an inline style. Provide a command to retrieve the value of that element's width, storing only the numeric value in the articleWidth variable.
var articleWidth = parseInt(document.getElementsByTagName("article")[0].style.width);
Provide the JavaScript statement to run the setup() function when the page is loaded by a browser.
window.onload = setup;