DHTML Programming Questions & Answers

Explore model answers categorized by subjects like Java, HTML, DBMS, and more.

DHTML Programming Questions & Answers

How we used JavaScript with CSS?

Answer:
 Using CSS with JavaScript we can change the style of HTML elements.
Like
document.getElementById(id).style.property=new style

How you define HTML DOM?

Answer:
HTML DOM is an Document Object Model for HTML. HTML DOM is an standard set of objects and way to access and manipulate HTML document.

Using HTML DOM we can view whole HTML document as tree structure.Using this DOM tree we can access and manipulate all elements with their text and attributes.
 
Some important points about HTML DOM are given below:

  1. It is an standard object model and standard programming interface for HTML.
  2. HTML DOM is an platform and language dependent.
  3. It is an W3C standard to get,change,add or delete HTML element.

What is DHTML?

Answer:
 Definition of DHTML according to W3c(World Wide Web Consortium) is:

Dynamic HTML is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated.

 DHTML stands for Dynamic HTML.DHTML is not an language. Using DHTML we can use DOM, CSS , JavaScript and HTML together.

 We use DHTML to make the web pages dynamic and interactive.

Tell about technologies that we use in DHTML?

Answer:
Some technologies that we used in DHTMl are given below:
  1. JavaScript
  2. HTML DOM
  3. HTML EVENT
  4. CSS

JavaScript: It is an standard of scripting for HTML. Using JavaScript DHTML can control,access and manipulate HTML element.
 
HTML DOM: It is an Document Object Model which is an W3C Standard for HTML.Using HTML DOM is used to define standard to set of objects and to access and manipulate them for HTML.Using HTML DOM, DHTML can access and manipulate HTML elements.
 
HTML Events: It is an part of HTML DOM and used to handle HTML elements.We use DHTML with HTML Events to make web pages those perform action when event occour.
 
CSS: It is an W3C standard style and layout model made only for HTML. DHTML use JavaScript and DOM to change position and style of HTML elements.

How DHTML work with JavaScript?

Answer:
Using JavaScript we can made dynamic HTML content.
We can use document.write() to show dynamic content on your web page.Below I have given you HTML page which made dynamic after using JavaScript.This example will show current date.

 Example:
<html>
 <body>
 <script type=\"text/javascript\">
 document.write(Date());
 </script>
 </body>
 </html>

How we used JavaScript with HTML DOM?

Answer:
In HTML4, We use them to dynamically change the inner content and attributes of HTML elements.
 I have you example which shows you how to change the content of HTML element.

document.getElementById(id).innerHTML=new HTML

 We can change the attribute of an HTML element like that,

document.getElementById(id).attribute=new value

In HTML4, We use them to dynamically change the inner content and attributes of HTML elements. I have you example which shows you how to change the content of HTML element.

document.getElementById(id).innerHTML=new HTML We can change the attribute of an HTML element like that,document.getElementById(id).attribute=new value

How to use JavaScript with HTML event?

Answer:
In HTML4, we use HTML event to trigger the events than they perform their action.We can do like that when we click on event it will JavaScript.

Example:
onclick=JavaScript

How to change an HTML element using HTML DOM?

Answer:
 Here,I have given you example to change an HTML element using HTML DOM.

<html>
<body>
<h1 id=\"header\">This is your Old Header</h1><script type=\"text/javascript\">
document.getElementById(\"header\").innerHTML=\"This is your New Header\";
</script>
</body>
</html>


Output: This is your New Header

 In the above example it will store header with an id=\"header\". And get the element with id=\"header\" by using DOM.We used JavaScript to change the content of HTML.

How to change HTML Attribute using HTML DOM?

Answer:
I have given you example to change HTML Attribute by using HTML DOM.

Example:

<html>
<body>
<img id=\"image\" src=\"oldimage.gif\">
<script type=\"text/javascript\">
document.getElementById(\"image\").src=\"newimage.jpg\";
</script>
</body>
</html>

 In the above example we load an image on HTML document by using id=\"image\".Using DOM we get the element with id=\"image\".JavaScript that we used in example to changes the src attribute from oldimage.gif to newimage.jpg


How to Handle Events with DHTML?

Answer:
Event is use to trigger actions in the browser. When client click on the element, associated action will started.Like: an JavaScript will started when client click on element.

Using Event Handler we can do like that,When an event occur it will execute code associated with that element.  
Example:
In this example header will changes when client clicks.

<h1 onclick=\"this.innerHTML=\'abc!\'\">Click on this text</h1>

We can add a script in the head section and then we call the function from the event handler.

Example:

<html>
<head>
<script type=\"text/javascript\">
function changetext(id)
{
id.innerHTML=\"abc!\";
}
</script>
</head>
<body>
<h1 onclick=\"changetext(this)\">Click on this text</h1>
</body>
</html>

What is the difference between DHTML and HTML?

Answer:
 Some main difference between DHTML(Dynamic HTML) and HTML(Hyper Text Markup Language)are given below.

  1. Using DHTML we can use JavaScript and style sheets in our HTML page.
  2. Using DHTML we can insert small animations and dynamic menus into our HTML page.
  3. If use want that your web page display your DHTML effects(object or word can highlighted, larger,a different color etc) than you have to save your web page with .dhtml extension except .html or .htm .

How FontSize and Font Size is differ in DHTML?

Answer:
 font size is an attribute that we used in font tag.Where as font-size is an style property.

<font size=\"5\"> use in font tag.
 p{font-size:\"5\"} use in CSS.



What is the features of DHTML?

Answer:
 Some most important features of DHTML are given below:

Using DHTML we can change the tags and their properties.
It is use for Real-time positioning.
It is used to generate dynamic fonts (Netscape Communicator).
Used for Data binding (Internet Explorer).