1. What is Java Script? List out uses of Java Script.?
Ans.
JavaScript is a scripting language used to make interactive web pages. It is mostly used as a client side scripting language. Its uses include:
n Control document appearance and content
n Control the browser
n Interact with document content
n Interact with user
n Read and write client state with cookies
n Interact with applets
n Manipulate embedded images
2. Create an HTML page, which pops up an alert message.
Ans.
Following HTML pops up an alert message:
<html>
<head>
<title>Pop up</title>
</head>
<body>
<h1>Trying Pop-ups</h1>
<script language = “JavaScript”>
alert(“This is an alert message. It uses alert() in JavaScript”);
</script>
</body>
</html>
3. Explain briefly about Cascading Style Sheets (CSS).
Ans.
CSS controls the look and placement of elements on a page. With CSS you can set any style property of any element on a HTML page. One of the biggest advantages with CSS instead of regular way of changing the look of elements is that you can split content from design. You can, for instance, link a CSS file to all the pages in your site that sets the look of the pages. So if you want to change the elements on the page, such as font size of the main text, you can just change it in the CSS and all the pages will be updated.
The syntax of CSS code is:
<style type =”text/css”>
ELEMENT [{property1:value1:property2:value2}]
</style>
Note that the style tag is always placed in the head of the document.
4. Explain the uses of script tags.
Ans.
The script tag marks the beginning and end of JavaScript in a web page. You can specify the scripting language in the script tags’ Language attribute. In addition, you can also specify where the script is expected to run using the runat attribute. For example, when JavaScript is used as a server side scripting language, you can use the script tag as:
<SCRIPT Language = “JavaScript” runat = “server”>
</SCRIPT>
5. Explain Document Object Model.
Ans.
The Document Object Model or DOM is the interface that allows you to programmatically access and manipulate content of a web page. It provides a structured, object-oriented, representation of the individual elements and content in a page with methods for retrieving and setting the properties of those objects. It also provides methods for adding and removing such objects, allowing you to create dynamic content.
The DOM also provides an interface for dealing with events, allowing you to capture and respond to user and browser actions.
6. Write a program to display text in status bar on click of a button.
Ans.
<html>
<head>
<title>Pop up</title>
</head>
<body onclick = “window.status = ‘You have clicked!!!’”>
<h1>Changing Status Bar Text</h1>
</body>
</html>
7. What is the difference between HTML and DHTML?
Ans.
HTML is a markup language used to create static web pages. DHTML on the other hand is not a language by itself but a combination of different technologies such as HTML, CSS, JavaScript, and DOM. It is used to create dynamic pages.
8. Explain the methods to access nodes in a Document tree.
Ans.
Following are the methods used to access a node in a document tree:
n document.getElementById(): Returns the element or node whose ID is passed as a parameter to it.
n document.getElementsByTagName(): Returns the list of nodes that have the tag passed to the function as a parameter.
9. What are text nodes?
Ans.If a node contains text, it is represented as a text node. For example, in<p id-node2>”This is the <b>initial</b>text.</p>, there are text nodes “This is the”, “initial”, and “text”.