Question: javascript Question 10 (1 point) Code Example 7-2 JavaScript code for an Image Swap 1. var $ = function(id) { 2. return document.getElementById(id); 3. };

javascript

Question 10 (1 point)

Code Example 7-2 JavaScript code for an Image Swap 1. var $ = function(id) { 2. return document.getElementById(id); 3. }; 4. window.onload = function() { 5. var listNode = $("image_list"); 6. var captionNode = $("caption"); 7. var imageNode = $("main_image"); 8. var imageLinks = listNode.getElementsByTagName("a"); 9. var i, image, linkNode, link; 10. for ( i = 0; i < imageLinks.length; i++ ) { 11. linkNode = imageLinks[i]; 12. image = new Image(); 13. image.src = linkNode.getAttribute("href"); 14. linkNode.onclick = function(evt) { 15. link = this; 16. imageNode.src = link.getAttribute("href"); 17. captionNode.firstChild.nodeValue = link.getAttribute("title"); 18. if (!evt) { evt = window.event; } 19. if (evt.preventDefault) { evt.preventDefault(); } 20. else { evt.returnFalse = false; } 21. }; 22. } 23. imageLinks[0].focus(); 24. };

(Refer to Code Example 7-2) What does the this keyword on line 15 refer to?

Question 10 options:

the image thats currently being processed

the link thats currently being processed

the link that the user clicked on

the array of link nodes

Question 11 (1 point)

Code Example 7-2 JavaScript code for an Image Swap 1. var $ = function(id) { 2. return document.getElementById(id); 3. }; 4. window.onload = function() { 5. var listNode = $("image_list"); 6. var captionNode = $("caption"); 7. var imageNode = $("main_image"); 8. var imageLinks = listNode.getElementsByTagName("a"); 9. var i, image, linkNode, link; 10. for ( i = 0; i < imageLinks.length; i++ ) { 11. linkNode = imageLinks[i]; 12. image = new Image(); 13. image.src = linkNode.getAttribute("href"); 14. linkNode.onclick = function(evt) { 15. link = this; 16. imageNode.src = link.getAttribute("href"); 17. captionNode.firstChild.nodeValue = link.getAttribute("title"); 18. if (!evt) { evt = window.event; } 19. if (evt.preventDefault) { evt.preventDefault(); } 20. else { evt.returnFalse = false; } 21. }; 22. } 23. imageLinks[0].focus(); 24. };

(Refer to Code Example 7-2) What would happen if lines 18 through 20 were omitted?

Question 11 options:

The code would only work in older versions of IE.

Clicking on a link would open a new browser window or tab and display the image specified by the href attribute of the link.

Nothing would happen when the user clicks on one of the links.

Clicking on a link would cause the caption, but not the larger image, associated with the link to be displayed.

Question 12 (1 point)

Which of the following statements runs a function named newTimer once after 3 seconds?

Question 12 options:

setTimeout(newTimer, 3);

setTimeout(newTimer, 3000);

setInterval(newTimer, 3);

setInterval(newTimer, 3000);

Question 13 (1 point)

Which of the following statements cancels a timer that runs a function named newTimer?

Question 13 options:

var clearTimeout = clear(newTimer);

newTimer = clearTimeout();

clearTimeout(newTimer);

newTimer.onclick = clearTimeout();

Question 14 (1 point)

Which of the following statements runs a function named newTimer every 3 seconds?

Question 14 options:

setTimeout(newTimer, 3);

setTimeout(newTimer, 3000);

setInterval(newTimer, 3);

setInterval(newTimer, 3000);

Question 15 (1 point)

When creating a timer, the delay or interval is specified

Question 15 options:

in seconds

in milliseconds

in thousandths

in tenths of a second

Question 16 (1 point)

The easiest way to create a timer that will repeat its function at intervals but will begin immediately is to

Question 16 options:

have the timer call an anonymous function

specify 0 milliseconds as the interval

call the function before you create the timer

create a one-time timer that runs when the page loads and then use an the interval timer after that

Question 17 (1 point)

Code Example 7-3 The JavaScript:: 1. var $ = function(id) { 2. return document.getElementById(id); 3. }; 4. var timer; 5. var counter = 10; 6. var updateCounter = function() { 7. counter--; 8. $("counter").firstChild.nodeValue = counter; 9. if (counter <= 0) { 10. clearInterval(timer); 11. document.getElementById("counter").innerHTML = "Blastoff!"; 12. } 13. }; 14. window.onload = function() { 15. timer = setInterval ( updateCounter, 1000 ); 16. }; The HTML:

Countdown: 10

(Refer to Code Example 7-3) Which of the following statements about this code is true?

Question 17 options:

It creates a timer that displays a counter on the page that replaces the text Countdown.

It creates a timer that uses the setInterval() method to change the updateCounter value every 1000 milliseconds .

It creates a timer that counts down from 10 to 1 and displays "Blastoff!" in the span element when the counter variable reaches 0.

It will fail because a timer cannot count down.

Question 18 (1 point)

Code Example 7-3 The JavaScript:: 1. var $ = function(id) { 2. return document.getElementById(id); 3. }; 4. var timer; 5. var counter = 10; 6. var updateCounter = function() { 7. counter--; 8. $("counter").firstChild.nodeValue = counter; 9. if (counter <= 0) { 10. clearInterval(timer); 11. document.getElementById("counter").innerHTML = "Blastoff!"; 12. } 13. }; 14. window.onload = function() { 15. timer = setInterval ( updateCounter, 1000 ); 16. }; The HTML:

Countdown: 10

(Refer to Code Example 7-3) The timer in this code will update the counter

Question 18 options:

every 10 seconds

once, after a delay of 1000 milliseconds

immediately, when the page loads

every second for 10 times

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!