IT. Expert System.

VBS

Applying VBScript


Applying VBScript

HTML provides a means of including VBScript code in the form of the script element. Using the script element, VBScript can be included in a web page in two ways:

  • Internal Script
  • External Script

Internal Script

The Internal Script method includes the VBScript code directly in the markup by using the <script> tag, like this:

<script type="text/vbscript">
  document.write("Hello from VBScript");
</script>

Inside the <script> tag the type attribute is used to define the scripting language. In this case, the type is set to "text/vbscript". The actual VBScript is placed between the beginning (<script ...>) and ending (</script>) tags.

This method is a good choice for quickly testing a solution or adding code that is specific to a particular page.

External Script

The External Script method instructs the browser to download a separate VBScript file and execute it in the page. The src attribute points to the script file like any other URL:

<script src="myscript.vbs" type="text/vbscript">
</script>

Then, the myscript.vbs file would look like this:

document.write("Hello from VBScript");

In most cases, using an external script is the best solution for the following reasons:

  • Placing the VBScript code directly in the HTML file using the internal method makes the HTML files larger and harder to maintain
  • VBScript can easily be included in multiple pages just by including the same <script> tag

VBScript Placement

VBScript can be placed in the head and body sections of an HTML document.

Scripts Within <head>

VBScript can be placed within the <head> section of an HTML document using either the internal or external method. The following example shows an internal VBScript within the <head> element:

<html>
<head>
  <script type="text/vbscript">
    document.write("Hello from VBScript");
  </script>
</head>

<body>
  content goes here
</body>
</html> 

Scripts Within <body>

VBScript can be placed within the <body> section of an HTML document using either the internal or external method. In general, it is best to place code within the <body> section when it is not inside a function, or if the script writes page content. The following example shows VBScript writing a message within the body:

<html>
<head>
</head>

<body>

  <script type="text/vbscript">
    document.write("Hello from VBScript");
  </script>

</body>
</html>

Sometimes there are cases when it is necessary to place VBScript code within the <head> and the <body> sections. The following example shows VBScript within both sections:

<html>
<head>
  <script type="text/vbscript">
    function message()
    {
      document.write("Hello from 'head'<br />");
    }
  </script>
</head>

<body>

  <script type="text/vbscript">
    message();
    document.write("Hello from 'body'<br />");
  </script>
</body>
</html>

This produces the following result:

Hello from 'head'
Hello from 'body'


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 215 / . Delta: 0.02807 с