Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Practice InterviewNew Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

JavaScript Interview Questions and Answers

Ques 31. How do we get JavaScript onto a web page?

Ans. You can use several different methods of placing Javascript in you pages.
You can directly add a script element inside the body of page.
1. For example, to add the \"last updated line\" to your pages, In your page text, add the following:
<p>blah, blah, blah, blah, blah.</p>
<script type=\"text/javascript\" >
<!-- Hiding from old browsers
document.write(\"Last Updated:\" +
document.lastModified);
document.close();
// -->
</script>
<p>yada, yada, yada.</p>

(Note: the first comment, \"<--\" hides the content of the script from browsers that don\'t understand javascript. The \"// -->\" finishes the comment. The \"//\" tells javascript that this is a comment so javascript doesn\'t try to interpret the \"-->\". If your audience has much older browsers, you should put this comments inside your javascript. If most of your audience has newer browsers, the comments can be omitted. For brevity, in most examples here the comments are not shown. )
The above code will look like this on Javascript enabled browsers,
2. Javascript can be placed inside the element
Functions and global variables typically reside inside the <head> element.
<head>
<title>Default Test Page</title>
<script language=\"JavaScript\" type=\"text/javascript\">
var myVar = \"\";
function timer(){setTimeout(\'restart()\',10);}
document.onload=timer();
</script>
</head>

Javascript can be referenced from a separate file
Javascript may also a placed in a separate file on the server and referenced from an HTML page. (Don\'t use the shorthand ending <script ... />). These are typically placed in the <head> element.
<script type=\"text/javascript\" SRC=\"myStuff.js\"></script>

Is it helpful? Add Comment View Comments
Ques 32. How can JavaScript make a Web site easier to use? That is, are there certain JavaScript techniques that make it easier for people to use a Web site?
Ans. JavaScript\'s greatest potential gift to a Web site is that scripts can make the page more immediately interactive, that is, interactive without having to submit every little thing to the server for a server program to re-render the page and send it back to the client. For example, consider a top-level navigation panel that has, say, six primary image map links into subsections of the Web site. With only a little bit of scripting, each map area can be instructed to pop up a more detailed list of links to the contents within a subsection whenever the user rolls the cursor atop a map area. With the help of that popup list of links, the user with a scriptable browser can bypass one intermediate menu page. The user without a scriptable browser (or who has disabled JavaScript) will have to drill down through a more traditional and time-consuming path to the desired content.
Is it helpful? Add Comment View Comments
Ques 33. How to create arrays in JavaScript?
Ans. We can declare an array like this
var scripts = new Array();
We can add elements to this array like this

scripts[0] = \"PHP\";
scripts[1] = \"ASP\";
scripts[2] = \"JavaScript\";
scripts[3] = \"HTML\";

Now our array scrips has 4 elements inside it and we can print or access them by using their index number. Note that index number starts from 0. To get the third element of the array we have to use the index number 2 . Here is the way to get the third element of an array.
document.write(scripts[2]);
We also can create an array like this
var no_array = new Array(21, 22, 23, 24, 25);
Is it helpful? Add Comment View Comments
Ques 34. Where are cookies actually stored on the hard disk?
Ans. This depends on the user\'s browser and OS.
In the case of Netscape with Windows OS,all the cookies are stored in a single file called

cookies.txt
c:\\Program Files\\Netscape\\Users\\username\\cookies.txt
In the case of IE,each cookie is stored in a separate file namely username@website.txt.
c:\\Windows\\Cookies\\username@Website.txt
Is it helpful? Add Comment View Comments
Ques 35. How to set a HTML document\'s background color?
Ans. document.bgcolor property can be set to any appropriate color.
Is it helpful? Add Comment View Comments

Most helpful rated by users:

©2018 WithoutBook