Ensurepass.com : Ensure you pass the IT Exams
2018 Aug Microsoft Official New Released 70-480
100% Free Download! 100% Pass Guaranteed!
Programming in HTML5 with JavaScript and CSS3
Question No: 11 HOTSPOT – (Topic 1)
You are creating a web worker for an HTML5 application.
The following tasks must be performed from within the web worker:
-> Register an event listener for the web worker
-> Start and stop the web worker
You need to define a function that performs the required tasks.
Which code segment should you use? (To answer, select the appropriate option from the drop-down list in the answer area.)
Answer:
Explanation:
-
addEventListener
The addEventListener() method attaches an event handler to the specified element.
In context of a worker, both self and this refer to the global scope. The worker can either add an event listener for the message event, or it can define the onmessage handler to listen for any messages sent by the parent thread.
-
postmessage
Pass a message to the worker.
-
close()
Terminating Workers
Workers are resource-intensive; they are OS-level threads. Therefore, you do no want to create a large number of worker threads, and you should terminate the web worker after it completes its work. Workers can terminate themselves, like this:
self.close();
Question No: 12 – (Topic 1)
You are developing a customer web form that includes the following HTML.
lt;label id=quot;txtValuequot;X/labelgt;
Information from the web form is submitted to a web service. The web service returns the following JSON object.
{
quot;Confirmationquot;: quot;1234quot;, quot;FirstNamequot;: quot;Johnquot;
}
You need to display the Confirmation number from the JSON response in the txtValue label field.
Which JavaScript code segment should you use?
-
$(quot;#txtValuequot;).val = (JSONObject.Confirmation);
-
$(quot;#txtValuequot;).val (JSONObject.Confirmation);
-
$(quot;#txtValuequot;).text = (JSONObject.Confirmation);
-
$(quot;#txtValuequot;).text (JSONObject.Confirmation);
Answer: D Explanation: Incorrect:
not A, not B: A label object has no value attribute.
Reference: http://api.jquery.com/text/
Question No: 13 – (Topic 1)
You are creating a web form that users will use to enter their personal information. The form includes the following HTML.
You have the following requirements:
-> When a user enters an input box, the cell on the right must turn green.
-> When a user leaves an input box, the cell on the right must turn white.
You need to create the web form to meet these requirements.
Which code segment should you use? nth-child
-
Option A
-
Option B
-
Option C
-
Option D
Answer: A
Explanation: * The :nth-child(n) selector matches every element that is the nth child, regardless of type, of its parent.
n can be a number, a keyword, or a formula.
Example
Specify a background color for every lt;pgt; element that is the second child of its parent:
p:nth-child(2) { background: #ff0000;
}
-
parent.next()
Here: the cell to the right of the current cell. Reference: CSS3 :nth-child() Selector
Question No: 14 – (Topic 1)
You are developing a web application that consumes services from a third-party application. A web worker processes the third-party application requests in the background. A page in the application instantiates the web worker process.
You need to establish two-way communications between the web worker process and the page.
Which two actions will achieve this goal? (Each correct answer presents a complete solution. Choose two.)
-
From the web worker, use the onconnect event handler of the main page to capture events.
-
From the main page, use the onmessage event handler of the web worker to capture events.
-
From the web worker, use the onmessage event handler of the main page to capture
events.
-
From the main page, use the onconnect event handler of the web worker to capture events.
Answer: B,C
Explanation: * When postMessage() is called from the main page, our worker handles that message by defining an onmessage handler for the message event.
-
-
Server-Sent Events – One Way Messaging
A server-sent event is when a web page automatically gets updates from a server.
Receive Server-Sent Event Notifications
The EventSource object is used to receive server-sent event notifications:
Example
var source = new EventSource(quot;demo_sse.phpquot;); source.onmessage = function(event) {
document.getElementById(quot;resultquot;).innerHTML = event.data quot;lt;brgt;quot;;
};
Reference: http://www.w3schools.com/html/html5_serversentevents.asp http://www.html5rocks.com/en/tutorials/workers/basics/
Question No: 15 – (Topic 1)
You are developing an HTML5 web application that displays customer mailing address information.
The application loads addresses from a web service by using AJAX. The following code defines a Customer object and loads address data.
You need to implement the loadAddress function. Which code segment should you use?
-
Option A
-
Option B
-
Option C
-
Option D
Answer: C
Question No: 16 – (Topic 1)
You are developing an HTML5 web application and are styling text. You need to use the text-transform CSS property.
Which values are valid for the text-transform property?
-
hidden
-
blink
-
capitalize
-
line-through
Answer: C
Explanation: CSS Syntax
text-transform: none|capitalize|uppercase|lowercase|initial|inherit;
Example
Transform text in different elements: h1 {text-transform:uppercase;}
h2 {text-transform:capitalize;} p {text-transform:lowercase;}
Reference: CSS text-transform Property http://www.w3schools.com/cssref/pr_text_text-transform.asp
Question No: 17 – (Topic 1)
You are developing a customer web form that includes the following HTML.
lt;input id=quot;txtValuequot; type=quot;textquot; /gt;
A customer must enter a valid age in the text box prior to submitting the form.
You need to add validation to the control. Which code segment should you use?
-
Option A
-
Option B
-
Option C
-
Option D
Answer: D Explanation: val Return value
A string containing the value of the element, or an array of strings if the element can have multiple values
Question No: 18 HOTSPOT – (Topic 1)
You are developing an HTML5 application for a company. You apply the following style to a DIV element on a page.
You need to submit a draft illustration of the results of this code.
Which illustration should you submit? (To answer, select the appropriate illustration in the answer area.)
Answer:
Explanation:
Example: div {
border: 3px solid;
background: #b6aaaa; width: 200px;
height: 100px; top 10%;
left 10%;
border-radius: 25px 0px 25px 0px;
}
Result:
Question No: 19 – (Topic 1)
You are developing an application that uses a third-party JavaScript library named doWork().
The library occasionally throws an quot;object is null or undefinedquot; error with an error code of
-2146823281.
The application must:
-> Extract and handle the exceptions thrown by doWork()
-> Continue normal program execution if other exceptions occur
You need to implement the requirements. Which code segment should you use?
-
Option A
-
Option B
-
Option C
-
Option D
Answer: C
Explanation: * The try statement lets you test a block of code for errors. The catch statement lets you handle the error.
The JavaScript statements try and catch come in pairs: try {
Block of code to try
}
catch(err) {
Block of code to handle errors
}
-
object.number [= errorNumber]
Returns or sets the numeric value associated with a specific error. The Error object#39;s default property is number.
-
Example:
The following example causes an exception to be thrown and displays the error code that is derived from the error number.
try
{
// Cause an error. var x = y;
}
catch(e)
{
document.write (quot;Error Code: quot;); document.write (e.number amp; 0xFFFF) document.write (quot;lt;br /gt;quot;);
document.write (quot;Facility Code: quot;) document.write(e.numbergt;gt;16 amp; 0x1FFF) document.write (quot;lt;br /gt;quot;);
document.write (quot;Error Message: quot;) document.write (e.message)
}
The output of this code is as follows. Error Code: 5009
Facility Code: 10
Error Message: #39;y#39; is undefined
Reference: JavaScript Errors – Throw and Try to Catch; number Property (Error) (JavaScript)
Question No: 20 DRAG DROP – (Topic 1)
You are developing an online shopping application that accepts credit cards for payment.
If the credit card number is invalid, the application must: Generate an error
Assign quot;200quot; to the error number Assign quot;Invalidquot; to the error description
You need to write the code that meets the requirements.
How should you write the code? (To answer, drag the appropriate code segment or segments to the correct location in the answer area. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.)
Answer:
Explanation:
Example: throw new Error(200, quot;x equals zeroquot;);
100% Ensurepass Free Download!
–70-480 PDF
100% Ensurepass Free Guaranteed!
–70-480 Dumps
EnsurePass | ExamCollection | Testking | |
---|---|---|---|
Lowest Price Guarantee | Yes | No | No |
Up-to-Dated | Yes | No | No |
Real Questions | Yes | No | No |
Explanation | Yes | No | No |
PDF VCE | Yes | No | No |
Free VCE Simulator | Yes | No | No |
Instant Download | Yes | No | No |