HTML 5 Interview Questions and Answers (188) - Page 10

Which of the following tag represents the footer of a section in HTML5?

NOTE: This is objective type question, Please click question title for correct answer.
What is long polling?

In the case of long polling, the client sends request to the server.If the server has some information to send back to the client at that point of time, it will.Else,the server will keep the connection open but will not respond back to the client until the time it has the data.However, the client will make a poll to the server after a certain period of time to check for the availability of the data.Once the server has further data, it will send the response back to the client.As soon as the client receives the response back from the server, it again make a new request and the process goes on.

Step 1: Client send request to server
Step 2: Server checks if it has data to respond back or not
Step 3: If Server has data, it will give a response back to the client
Step 4: If not, it(Server) will keep the connection open.
Step 5: Client makes a further call to the server after a specified time interval.
Step 6: Repeat Step 2 to Step 4.
Step 7: Once Server has the data, it responded back to the client.
Which of the following is the disadvantage of Long Polling?

NOTE: This is objective type question, Please click question title for correct answer.
We need to call the open method by creating a WebSocket object inorder to make a WebSocket connection. How can we do that?

First of all, there is no "open" method on the WebSocket object. However, when we want to create a WebSocket object for establishing a connection, we basically instantiate the WebSocket object that does the trick.

e.g.

var uri ='ws://echo.websocket.org/';

var webSocket = new WebSocket(uri);

Can u please explain with a very basic example as how cilent-server communication happens via WebSocket

Please look into the below line of code segments (it is documented for easy understanding)

var webSocket;


//Step 1: Instantiate the WebSocket object
var webSocket = new WebSocket('ws://echo.websocket.org');

//check webSocket is not 'undefined and null'
if(!webSocket){

//Step 2: Check if the websocket is in OPEN state and henceforth the communication can be establish
if(webSocket.readyState == webSocket.OPEN){

//Step 3: Client send a message to the server once the connection opens
webSocket.send("Message from Client");

//Step 4: Server sends a response back to the client
webSocket.onmessage = function(e){
console.log("Message from Server" + e.data);
}
}
}

How a secure WebSocket URL begins with?

NOTE: This is objective type question, Please click question title for correct answer.
What is DOM ?

The HTML DOM is a standard object model and programming interface for HTML. It defines:

- The HTML elements as objects
- The properties of all HTML elements
- The events for all HTML elements
- The methods to access all HTML elements


e.g.

<html>

<head>
<title>Simple HTML</title>
<script type="javascript">

function LoadMeFirst(){
alert("Html Dom loading.....");
}
function ClickME(){
alert("Dom Loaded and hence the button is clicked");
var accessingTheParagraphText = document.getElementsByTagName('p')[0].innerHTML;
}

</script>
</head>
<body onLoad="LoadMeFirst()">
<p>A simple paragraph</p>
<input type="button" id="myButton" value="MyButton" onClick="ClickME()" />
</body>
</html>


In the above example,

- The HTML elements are - HTML,HEAD,TITLE,BODY,P,INPUT
- The button properties are - TYPE,ID,VALUE
- The Event for

a) BODY is: onLoad
b) BUTTON is: onClick
- Method to access the HTML elements - getElementsByTagName
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories