Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

what is the difference between <%@ LANGUAGE = VBScript %> and <SCRIPT LANGUAGE="VBScript"> ?

Hi,

what is the difference between <%@ LANGUAGE = VBScript %> and <SCRIPT LANGUAGE="VBScript"> ?

The follows are two parts of codes, the first one works, but the second one doesn't work.

The error information is: "Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'document' ".

 Is there any possibility to make the second one work? Thanks.

The first one:

<HTML>
<HEAD>
<TITLE>Document.Write Examples</TITLE>
</HEAD>
<BODY BGCOLOR=WHITE>
This line is part of the regular body text.
<P>
<SCRIPT LANGUAGE="VBScript">
' This line runs when the browser parses the script
Call WriteGreeting
Sub WriteGreeting
    Dim hr
    hr = Hour(Now)
    If hr < 12 Then
        document.write "Good morning!"
    ElseIf hr < 17 Then
        document.write "Good afternoon!"
    Else
        document.write "Good evening!"
    End If
End Sub
</SCRIPT>
<P>
Another line of body text.
<P>
<SCRIPT LANGUAGE="VBScript">
' These statements are executed at parse-time
document.write "You're visiting at "
document.write Time() & " on " & Date() & "."
</SCRIPT>
</BODY>
</HTML>



 
The second one:

<%@ LANGUAGE = VBScript %>

<HTML>
<HEAD>
<TITLE>Document.Write Examples</TITLE>
</HEAD>
<BODY BGCOLOR=WHITE>
This line is part of the regular body text.
<P>
<%
' This line runs when the browser parses the script
Call WriteGreeting
Sub WriteGreeting
    Dim hr
    hr = Hour(Now)
    If hr < 12 Then
        document.write "Good morning!"
    ElseIf hr < 17 Then
        document.write "Good afternoon!"
    Else
        document.write "Good evening!"
    End If
End Sub
%>
<P>
Another line of body text.
<P>
<%
' These statements are executed at parse-time
document.write "You're visiting at "
document.write Time() & " on " & Date() & "."
%>
</BODY>
</HTML>
0
HobbyTown
Asked:
HobbyTown
1 Solution
 
brunoCommented:
<%@ LANGUAGE = VBScript %> tells the SERVER that the script located between the delimiters <% %> is VBScript.

<SCRIPT LANGUAGE="VBScript"> tells the BROWSER that the following script is VBScript.


so no, your second example will not work, because it's the server tyring to execute that code, not the browser.
0
 
HobbyTownAuthor Commented:
Thanks.
0
 
rdivilbissCommented:
HobbyTown,

Are you aware that only IE supports VBcript?  Non IE browsers visiting that page will not work.

FYI only,
Rod
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Dave_DietzCommented:
None of this appears to be client side script.

Generally VBScript will be processed on the server (as ASP) and the client really doesn't matter....

Dave Dietz
0
 
elleonsengaCommented:
Hi

to make the second code works, you have to replace all the "decument.write" with "response.write" as response.write is a function in VBScript but not document.write.

So, your second part of code should be like this:
==================================
<%@ LANGUAGE = VBScript %>

<HTML>
<HEAD>
<TITLE>Document.Write Examples</TITLE>
</HEAD>
<BODY BGCOLOR=WHITE>
This line is part of the regular body text.
<P>
<%
' This line runs when the browser parses the script
Call WriteGreeting
Sub WriteGreeting
    Dim hr
    hr = Hour(Now)
    If hr < 12 Then
        response.write "Good morning!"
    ElseIf hr < 17 Then
        response.write "Good afternoon!"
    Else
        response.write "Good evening!"
    End If
End Sub
%>
<P>
Another line of body text.
<P>
<%
' These statements are executed at parse-time
response.write "You're visiting at "
response.write Time() & " on " & Date() & "."
%>
</BODY>
</HTML>
================================

Hope this helps.
0
 
brahmankarnikhilCommented:
Hi hobbytown,
the first syntax is (<%@ LANGUAGE = VBScript %>) to specify that the script whatever u r defining should get executed at server side and the second syntax is (<SCRIPT LANGUAGE="VBScript">) to specify that the script whatever u r defining is a client side script. Ur second code snippet is just like ASP (server side execution) & there is no object Document in ASP Objects where as ur first code Client side script in which u've got a object called Document.

That's why ur second code is not working & giving an error!

I hope this will clear ur confusion!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now