JavaScript Interview Questions and Answers (294) - Page 5

What is Raphael?

Raphael is a small JavaScript library which simplifies drawing the vector graphics easily on the web. Creation of custom chart or cropping of images or rotating the widgets are now very easy with the Raphael library.
It uses the SVG W3C Recommendation and VML as a base for creating graphics.
Browser that supports the Raphael library.

NOTE: This is objective type question, Please click question title for correct answer.
Can we attach Javascript event handlers to the Raphael objects?

NOTE: This is objective type question, Please click question title for correct answer.
Give an example of JavaScript Print ?

<input type="button" value="Print this Page" onclick="window.print();">



JavaScript automatically opens a print dialogue box so that users can print the page.


Thanks and Regards
Akiii
What is a JavaScript Escape Characters ?

In JavaScript, the backslash (\) is an escape character.

<script type="text/javascript">

<!--
document.write("The "escape" character");
//-->
</script>


As soon as the browser encounters the first double quote, it will think that the string has finished. Further, it will result in an error because it will be expecting the closing bracket.

<script type="text/javascript">

<!--
document.write("The \"escape\" character");
//-->
</script>



Thanks and Regards
Akiii
What is Extjs ?

ExtJs is JavaScript application framework that works on all following modern browsers.
IE 6+
Firefox 3.6+ (PC, Mac)
Safari 4+
Chrome 10+
Opera 11+ (PC, Mac

It enables you to develop the best Rich cross-platform applications. It also offers an extraordinary range of UI widgets like grids, trees, menus, and more.
Difference between InnerText and InnerHtml ?

The difference between innerText and innerHTML is innerText is interpreted as text where as innerHTML is interpreted as HTML.

Example:
<Div ID="Test"> <b>Test for InnerText and InnerHtml</b><Div>

1. document.getElementById('Test').innerHTML // output: <b>Test for InnerText and InnerHtml</b

2. document.getElementById('Test').innerText // output: Test for InnerText and InnerHtml
What is J.W.T ?

JSON Web Token (JWT) is a representing claims (represented as a name/value pair consisting of a Claim Name and a Claim Value) to be transferred between two parties.

Claim in JWT encoded as JSON Object used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or MACed and/or encrypted.
Inside which HTML element or tag do we put the JavaScript?

NOTE: This is objective type question, Please click question title for correct answer.
How do we round the number 9.25 to the nearest integer?

NOTE: This is objective type question, Please click question title for correct answer.
What is the correct syntax for referring to an external Javascript file?

NOTE: This is objective type question, Please click question title for correct answer.
How to assign a value to a textbox through javascript?

NOTE: This is objective type question, Please click question title for correct answer.
What is the correct JavaScript syntax to write "Hello World"?

NOTE: This is objective type question, Please click question title for correct answer.
How do we write "Hello World" in an Alert Box?

NOTE: This is objective type question, Please click question title for correct answer.
How to write an IF statement in JavaScript?

NOTE: This is objective type question, Please click question title for correct answer.
How can we detect the client's Browser Name in Javascript?

NOTE: This is objective type question, Please click question title for correct answer.
Where is the correct place to insert a JavaScript?

NOTE: This is objective type question, Please click question title for correct answer.
How do we call a Javascript function from code-behind?

Suppose,we have a Javascript function as below:-

<script type="text/javascript">

function alert_msg()
{
alert("Vishal Kumar");
}
</script>


To call above function from Code behind,write below code in any button click:-


ScriptManager.RegisterStartupScript(Page, typeof(Page), "message", "javascript:alert_msg();", true);

Is JavaScript case sensitive?

Yes,it's purely case-sensitive.

For ex:-

we can write getElementById function not getElementbyID.
we can write function not Function.
we can write ClientID not clientId or Clientid.

We can understand all cases by simple example:-

function do_stuff()

{
var txt_name = document.getElementById ('<%=txt_name.ClientID %>');
}


Explanation:-

Function ->Will give run-time error as
"Expected ';' and JavaScript runtime error: 'do_stuff' is undefined"

getElementByID -> It will show run-time error as
"Object doesn't support property or method 'getElementByID'"

ClientID -> If we provide ClientId or clientId then it will give compile-time error as

"System.Web.UI.WebControls.TextBox' does not contain a definition for 'ClientId' and no extension method 'ClientId' accepting a first argument of type 'System.Web.UI.WebControls.TextBox' could be found (are you missing a using directive or an assembly reference?)"

How do we submit a form using JavaScript?

We can write document.forms[0].submit() to submit a form in Javascript.

The submit() method submits the form same as submit button in HTML.It has no return value.Generally a Form is submitted,when we click on Submit Button.

<script type="text/javascript">

function submitform()
{
document.forms["frm_admin"].submit();
//or we can also write as
//document.getElementById("frm_admin").submit();
}
</script>


<input type="button" name="submit" value="Submit" onclick = "submitform();"/>
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