HTML.and.XHTML.The.Complete.Reference.4th.Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

HTML.and.XHTML.The.Complete.Reference.4th.Edition [Electronic resources] - نسخه متنی

Thomas Powell

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید








VBScript


Visual Basic Scripting Edition, generally called VBScript, is a subset of the popular Visual Basic language. Because of its Visual Basic heritage, in some ways VBScript is somewhat better defined and seems to have a more stable specification than JavaScript. VBScript is less prevalent than JavaScript on the Internet, largely because VBScript is fully supported in only Internet Explorer browsers. The language can be used to provide the same functionality as JavaScript, and is just as capable as accessing the various objects that compose a Web page (termed a browser's Object Model). Given its Internet Explorer limitation, avoid trying to use VBScript as a cross-platform scripting solution. However, used in a more controlled environment, such as an intranet, VBScript might just be what the Microsoft-oriented developer needs. The following is a sample of VBScript to give you a flavor of its syntax; this example has the same functionality as the JavaScript example given previously:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>VBScript Example</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<script type="text/vbscript">
<!--
Sub greet_OnClick
MsgBox "Hello user! Welcome to VBScript."
End Sub
-->
</script>
</head>
<body>
<h1 align="center">First VBScript Example</h1>
<div align="center">
<form action="#">
<input type="button" value="Press Me" name="greet" />
</form>
</div>
</body>
</html>

This is a simple example of how VBScript can be included in an XHTML file and should produce a rendering similar to the one shown in Figure 14-2.


Figure 14-2: VBScript says hello

As in the first example, the form button named "greet" triggers an alert box that greets the user. Notice that rather than using an explicit XHTML attribute such as onclick, as was used in the JavaScript example, the VBScript example names the subroutine in a certain way to associate it with the button event; in this case, greet_OnClick. Other differences with the VBScript example include the use of the MsgBox function to create the alert window, as well as syntactical differences such as the use of parentheses. Readers familiar with Visual Basic should find this example very easy because this language is just a subset of Visual Basic proper.

Once again, though, as a client-side technology, VBScript is not really very useful because it is limited to Internet Explorer. Relying on VBScript locks out others such as Netscape, Opera, or Safari users, which is unacceptable for a public Web site. Because of this, VBScript often is limited to being used within a Microsoft-oriented intranet or on the server side, in the form of Active Server Page code (as discussed in Chapter 13). No further discussion of VBScript occurs during this client-side discussion. However, readers interested in more information about the syntax of VBScript, as well as examples, are encouraged to visit Microsoft's scripting site (http://msdn.microsoft.com/scripting/).


/ 252