Sie sind auf Seite 1von 7

HTML DOM

The HTML DOM defines a standard way for accessing and manipulating
HTML documents.

The DOM presents an HTML document as a tree-structure.

HTML DOM Tree Example


HTML DOM Introduction

The HTML DOM defines a standard for accessing and manipulating HTML documents.

What is the DOM?


The DOM is a W3C (World Wide Web Consortium) standard.

The DOM defines a standard for accessing documents like HTML and XML:

"The W3C Document Object Model (DOM) is a platform and language-neutral interface that
allows programs and scripts to dynamically access and update the content, structure, and style
of a document."

The DOM is separated into 3 different parts / levels:

• Core DOM - standard model for any structured document


• XML DOM - standard model for XML documents
• HTML DOM - standard model for HTML documents

The DOM defines the objects and properties of all document elements, and the methods
(interface) to access them.

What is the XML DOM?


The XML DOM defines the objects and properties of all XML elements, and the methods
(interface) to access them.

What is the HTML DOM?


The HTML DOM is:
• A standard object model for HTML
• A standard programming interface for HTML
• Platform- and language-independent
• A W3C standard

The HTML DOM defines the objects and properties of all HTML elements, and the methods
(interface) to access them.

In other words: The HTML DOM is a standard for how to get, change, add, or delete
HTML elements.

VBScript Editor
With our online editor, you can edit the VBScript code, and click on a button to view the result.

Example (IE Only)


<html>
<body>

<script type="text/vbscript">
document.write("This is my first VBScript!")
</script>

</body>
</html>

VBScript Introduction

What is VBScript?
• VBScript is a scripting language
• A scripting language is a lightweight programming language
• VBScript is a light version of Microsoft's programming language Visual Basic
• VBScript is only supported by Microsoft's browsers (Internet Explorer)

How Does it Work?


When a VBScript is inserted into an HTML document, Internet Explorer browser will read the
HTML and interpret the VBScript. The VBScript can be executed immediately, or at a later
event.

VBScript only works in Microsoft browsers (Internet Explorer).

VBScript How To

The HTML <script> tag is used to insert a VBScript into an HTML page.
Put a VBScript into an HTML Page
The example below shows how to use VBSript to write text on a web page:

Example (IE Only)


<html>
<body>
<script type="text/vbscript">
document.write("Hello World!")
</script>
</body>
</html>

The example below shows how to add HTML tags to the VBScript:

Example (IE Only)


<html>
<body>
<script type="text/vbscript">
document.write("<h1>Hello World!</h1>")
</script>
</body>
</html>

Example Explained
To insert a VBScript into an HTML page, we use the <script> tag. Inside the <script> tag we use
the type attribute to define the scripting language.

So, the <script type="text/vbscript"> and </script> tells where the VBScript starts and ends:
<html>
<body>
<script type="text/vbscript">
...
</script>
</body>
</html>

The document.write command is a standard VBScript command for writing output to a page.

By entering the document.write command between the <script> and </script> tags, the browser
will recognize it as a VBScript command and execute the code line. In this case the browser will
write Hello World! to the page:

<html>
<body>
<script type="text/vbscript">
document.write("Hello World!")
</script>
</body>
</html>

How to Handle Simple Browsers


Browsers that do not support scripting, will display VBScript as page content.

To prevent them from doing this, the HTML comment tag should be used to "hide" the
VBScript.
Just add an HTML comment tag <!-- before the first VBScript statement, and a --> (end of
comment) after the last VBScript statement, like this:

<html>
<body>
<script type="text/vbscript">
<!--
document.write("Hello World!")
-->
</script>
</body>
</html>