?
Solved

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

Posted on 2005-03-21
8
Medium Priority
?
357 Views
Last Modified: 2008-02-01
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
Comment
Question by:HobbyTown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 18

Accepted Solution

by:
bruno earned 1000 total points
ID: 13595024
<%@ 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
 

Author Comment

by:HobbyTown
ID: 13595279
Thanks.
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13595444
HobbyTown,

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

FYI only,
Rod
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 34

Expert Comment

by:Dave_Dietz
ID: 13597338
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
 

Expert Comment

by:elleonsenga
ID: 13597836
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
 

Expert Comment

by:brahmankarnikhil
ID: 13599272
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to count occurrences of each item in an array.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question