Wednesday 24 October 2012

Use of Scripting as Language support:

The web is by nature client/server environment. The server stores information, client does processing. With VB script, you can add small programs to your pages that are executed on the server.
Web pages are by definition interactive, each time when we click hyperlink, we are taken to another page. This type of interaction requires trip to server at each step. The web page cant response to events, such as click of button because HTML is not a programming language. It cannot display date or simple calculations.
            The latest trend in web design is to make pages active. A active page behaves like an application. It has its own interface, composed of common windows element & interacts to visitors in manner similar to windows application.
            SCRIPT is an embedded application. Script are simple programs, embedded in HTML pages as ASCII text, When the page is downloaded, the script is downloaded with it and is executed by browser on client computer.
            VB script is lightweight version of Visual Basic. You can insert  script in HTML document.
<SCRIPT>tag:
The VB script can be placed in <SCRIPT> start tag & </SCRIPT> end tag. You need to mention attribute LANGUAGE=”VBScript” as shown below.
<SCRIPT LANGUAGE=”VBScript”>
Your scripting code
</SCRIPT>
When browser hits <SCRIPT >tag ,it calls VB script interpreter to compile & execute the code.
EXCERSIZE 9:
Write a HTML code for VB Script DEMO
HTML code:
<HTML>
<HEAD>
<TITLE> VB SCRIPT DEMO</TITLE>
<SCRIPT LANGUAGE=”VBScript”>
Document.fgcolor=”h ff 0000”
Document.bgcolor=”h 00 ffff”
Msgbox “WELCOME TO VB SCRIPT”
</SCRIPT>
</HEAD>
<BODY>
<H1>VB SCRIPT DEMO</H1>
</BODY>
</HTML>


EXCERSIZE 10:
Write a HTML code for VB Script TO display local time & day.
HTML code:
<HTML>
<HEAD>
<TITLE> LOCAL TIME & DAY</TITLE></HEAD>
<BODY>
<H1> LOCAL TIME & DAY </H1><HR>
The local time is now
<SCRIPT LANGUAGE=”VBScript”>
Document. Write Time() & “on” & -
Month Name(Month(Now),False)&””&Day(Now)-
&”,”&Year(Now)
</SCRIPT>
</BODY>
</HTML>

EXCERSIZE 12:
Write a HTML code with VB script for a webpage which greets “Good Morning” if time is 12:00am to 12:00 pm else greets “Good Afternoon”
HTML code:
<HTML>
<HEAD>
<TITLE> Greeting</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE=”VBScript”>
Function Greeting()
If time()>=#12:00 AM # And Time()_
            <#12:00:00PM# Then_
            Greeting=”GOOD MORNING!!!”_
ELSE_
            Greeting=”GOOD AFTERNOON!!!”_
EndIf
End Function
Document.write.greeting()
</SCRIPT>
<BR>
</BODY></HTML>

2 comments: