ch 9 -11 practice

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is the correct syntax of changing the CSS style of an HTML element? A htmlelement.style = property : value; B htmlelement.property = style : value; C htmlelement.property.style = value; D htmlelement.style.property = value;

D htmlelement.style.property = value;

Which of the following information is not a part of the cookie header? A username=username B path=path C domain=domain D expires=date

A username=username

Which of the following uses of a cookie may compromise a user's security? A Authenticate a user. B Store a user's browsing history. C Maintain user state. D Store user preference.

A Authenticate a user.

Which of the following is a major advantage of using the appendChild() method? A It can be used to add elements to the DOM without overwriting the existing page. B It can be used to remove form elements. C It can be used to reorganize the DOM, and overwrite the existing page. D It can be used to overwrite the existing elements in a Web page.

A It can be used to add elements to the DOM without overwriting the existing page.

Consider the following code: <form action="#" name="myForm" method="get"> <input type="text" value="What color is the sky?" name="firstvalue"/> <button onclick="document.myForm.elements[0].setAttribute('style', 'background: #CCFFFF'); return false;">Click Me to Find Out</button> </form> What is the expected result when this script is run in the browser? A The background of the text box will change to blue. B The background of the button will change to blue. C The background of the page will change to blue. D The background of the form will change to blue.

A The background of the text box will change to blue.

Consider the following code block: <div class="class1" /></div> <div class="class1 class2" /></div> <div class="class3" /></div> <div class="class1 class2" /></div> Which of the following statements will select elements that have multiple classes? A document.getElementsByClassName("class1 class2 ") B document.getElementsByClassName("class1.class2.class3") C document.getElementsByClassName("class1,class2,class3") D document.getElementsByClassName("class1;class2;class3")

A document.getElementsByClassName("class1 class2 ")

Which example shows proper JavaScript syntax for referring to a form object named newForm having a text box named fieldName? A document.newForm.fieldName.value; B window.newForm.fieldName.value; C form.newForm.fieldName."value" D document.newForm[fieldName].value;

A document.newForm.fieldName.value;

Which property of the form object returns the number of elements in the form? A length B target C encoding D elements

A length

Consider the following select list: <select id="numlist"> <option value="a">Alpha</option> <option value="b">Beta</option> <option value="c">Charlie</option> <option value="d">Delta</option> </select> Which of the following will select the third option in the list? A document.getElementById("numlist").selected = 3; B document.getElementById("numlist").options.selectedIndex = 2; C document.getElementById("numlist").options[2].selectedIndex(); D document.getElementById("numlist")[3].selected(true);

B document.getElementById("numlist").options.selectedIndex = 2;

What will happen when the Confirm Box button is clicked? A Regardless of user action, the alert box that says "The box is checked" will display due to a coding error. B An error will return because the wrong form is identified in the if statement. C Depending on user action, one of the two alert boxes will display. D Regardless of user action, the alert box that says "The box is not checked at the moment" will display due to a coding error.

B An error will return because the wrong form is identified in the if statement.

Which of the following is true of JavaScript security? A Cookies carry no security threat. B Browser detection helps in targeting attacks on vulnerabilities in a browser. C Cloaking improves the security of a Web page. D Disabling JavaScript is the only way to prevent security threats.

B Browser detection helps in targeting attacks on vulnerabilities in a browser.

Which property is used to add CSS styles to elements in a Web page? A HTMLElement.cssStyle B HTMLElement.style C HTMLElement.addStyle D HTMLElement.styles

B HTMLElement.style

Which browser security consideration should a JavaScript developer remember when developing a script? A JavaScript functionality is immune to viruses, trojans and malware. B JavaScript can be disabled by the user and therefore cannot be relied upon to run. C JavaScript is a cross-platform scripting language and will generate consistent results regardless of the client or server being used. D Certain JavaScript functionality is built into browsers and has been tested by the browser developers so it cannot be disabled by the user because it is deemed safe.

B JavaScript can be disabled by the user and therefore cannot be relied upon to run.

In Web development, what is the ability to change HTML "on the fly"? A To change a Web site from static content to interactive content B To change HTML on a Web page when needed, even after it renders C To change Web page content from X/HTML to JavaScript D To change Web page content by requesting user input

B To change HTML on a Web page when needed, even after it renders

Which attribute of the file object is used to define the types of file to be uploaded? A file B accept C filetype D type

B accept

Which of the following methods of an HTML form object removes focus from an input element? A remove() B blur() C focus() D autofocus()

B blur()

Consider the following HTML form: <form id="f1"> <select id="brand" disabled> <option value="">Please select a brand</option> <option value="true">BMW</option> <option value="Audi">Audi</option> </select> </form> Which of the following expressions will allow a user to interact with the select statement? A document.forms[0].elements[0].canEdit = true; B document.forms[0].elements[0].disabled = false; C document.forms[0].elements[0].hidden = false; D document.forms[0].elements[0].enabled = true;

B document.forms[0].elements[0].disabled = false;

<html> <head> </head> <body> <p>What's your favorite color?</p> <form name="myForm"> <input type="radio" name="rdoGroup1" id="opt1" value="Red"/>Red<br/> <input type="radio" name="rdoGroup1" id="opt2" value="Orange"/>Orange<br/> <input type="radio" name="rdoGroup1" id="opt3" value="Purple"/>Purple<br/> </body> </html> Which of the following methods could be used to change the value of the first radio button? A document.rdoGroup1.value = "Green" B document.myForm.rdoGroup1[0].value = "Green" C document.getElementById(rdoGroup1).value = "Green" D document.getElementById("rdoGroup1").value = "Green"

B document.myForm.rdoGroup1[0].value = "Green"

Which event handler of the select object specifies the JavaScript code to execute when a user moves the cursor to the select list? A onsubmit B onfocus C onchange D onblur

B onfocus

Which of the following adds a color picker on the Web page and specifies the default color as red? A <input type="color" default="red" /> B <input type="picker" value="red" /> C <input type="color" value="red" /> D <input type="picker" default="red" />

C <input type="color" value="red" />

What happens if your script runs the document.write method after the page is rendered (i.e., finished loading)? A It will append the document.write content to the end of the page without overwriting the existing page content. B It will append the document.write content to the beginning of the page without overwriting the existing page content. C It will remove all content and code that was previously on the page and render only the document.write content. D The document.write content will not be added to the page at all.

C It will remove all content and code that was previously on the page and render only the document.write content.

A user enters confidential data on a Web site while performing a task. This data was redisplayed on the Web page, after the task was completed. The data sent between the server and browser was not encoded as HTML entities. Which of the following vulnerabilities will this result? A Cloaking B DOM-based XSS C Non-persistent XSS D Persistent XSS

C Non-persistent XSS

Which of the following is least likely to pose a security threat for a user? A Cookies B Cloaking C Signed scripts D XSS

C Signed scripts

Consider the following code: <form action="#" name="myForm" method="get"> <input type="text" value="Type here" name="firstvalue"/> <button onclick="document.myForm.elements[1].disabled=true; return false;">Surprise!</button> </form> What is the expected result of clicking the button? A Nothing will change. B The text field will become unresponsive. C The button will become unresponsive. D The form will disable itself.

C The button will become unresponsive.

What two parameters does the setAttribute() method take? A The name of the attribute to remove and its replacement attribute B The name and the id of the attribute to retrieve C The name of the attribute to set and its new value D The name of the element and the attribute to set

C The name of the attribute to set and its new value

Which of the following properties is not applicable to the select element? A selectedIndex B options C checked D value

C checked

Consider the following HTML form: <form id="f1"> <input type="text" value="Enter name" /> <select id="brand"> <option value="">Please select a brand</option> <option value="true">BMW</option> <option value="Audi">Audi</option> </select> <input type="submit" /> </form> Which of the following expressions will make sure that a user enters a value in the text field before submitting the form? A document.forms[0].elements[0].value = required; B document.forms[0].elements[0].checkValidity = true; C document.forms[0].elements[0].required = true; D document.forms[0].elements[0].name = required;

C document.forms[0].elements[0].required = true;

Which of the following will correctly retrieve the corresponding value of an HTML element's attribute within the DOM? A setAttribute(AttributeName, NewValue) B setAttribute(AttributeName) C getAttribute(AttributeName) D getAttribute(AttributeName, NewValue)

C getAttribute(AttributeName)

Which event handler of the select object specifies the JavaScript code to execute when the select object loses focus after a user makes a selection, but only if the user selects an option other than the default? A onclick B onblur C onchange D onfocus

C onchange

Which event is triggered on the <select> element when the selection is modified? A onselect B onfocus C onchange D onblur

C onchange

Which form object will you use to mask the value entered by a user (i.e., hide the actual value of the input)? A disabled B hidden C password D text

C password

Question 19 : Consider the following HTML code block: <body><p id="eg"></p></body> What will be the output of the following expressions? 1: document.getElementById("eg").innerHTML = "<b><i>Sample text.</i></b>"; 2: document.getElementById("eg").innerText = "<b><i>Sample text.</i></b>"; A 1: <b><i>Sample text.</i></b> 2: Sample text. B 1: <b><i>Sample text.</i></b> 2: <b><i>Sample text.</i></b> C 1: Sample text. 2: Sample text. D 1: Sample text. 2: <b><i>Sample text.</i></b>

D 1: Sample text. 2: <b><i>Sample text.</i></b>

Which of the following is true of the getElementById() method? A If multiple elements have the same id attribute, it may return a reference to any of the elements. B It returns an array of all the elements with a specified id. C It returns the last element in the document with a specified id. D It returns the first occurrence of an element in a document with the specified id.

D It returns the first occurrence of an element in a document with the specified id.

Consider the following code block: if (document.cookie) document.cookie = "testExample=Test;expires=20-May-1910"; else alert("no"); alert(document.cookie); On executing the script, an alert box is displayed on the page that does not contain the testExample cookie. Why was the cookie not displayed? A The user's browser may not support cookies. B The last alert message is syntactically wrong, it must be alert(document.cookie.testExample);. C The condition in the if block did not evaluate to true. D The cookie was not created because the properties of the cookie didn't allow for creation.

D The cookie was not created because the properties of the cookie didn't allow for creation.

Which of the following should be done while adding validation to a form? A Test the form validation on a single browser. B Test multiple fields in one validation. C Alert messages should be discursive. D Validations should not override each other.

D Validations should not override each other.

Consider the following HTML block: <select id="car"> <option value="">Please select a brand</option> <option value="BMW">BMW</option> <option value="Audi">Audi</option> <option value="Porsche">Porsche</option> </select> Which of the following expressions will change the selected index to 2? A brand.options[2].checked = true; B brand.options[2].value = true; C brand.options[2]= true; D brand.options[2].selected = true;

D brand.options[2].selected = true;

Which JavaScript event handler is triggered when a user clicks her mouse button outside of a particular field after typing input there? A onmouseout B onfocus C onclick D onblur

D onblur

Which form event handler executes the specified code when the value of an element is modified from the default? A onmodify B onsubmit C onfocus D onchange

D onchange


Set pelajaran terkait

Exam 2 Hematology Ch. 7 - Granulocytes & Monocytes - Quiz & Review Questions

View Set

Chapter 34 Aggregate Supply and Demand. Macroeconomics

View Set

Vocab. Ch. 9 - Skeletal Muscle Tissue

View Set

Ch. 4 Part 1 Exam Questions (Life) - Life Insurance Policies

View Set

Series 7 Chapter 16: U.S. Government and State Rules and Regulations

View Set

CHAPTER 48 CARE OF PATIENT WITH A CARDIOVASCULAR OR A PERIPHERAL VASCULAR DISORDER

View Set

Network+ Review Questions Sec. 8-12

View Set

Process and Skills Quizzes Week 4-8 (Exam #2)

View Set