|
Home > Archive > IIS ASP > June 2007 > HELP: ASP JScript & VBScript interoperability
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
HELP: ASP JScript & VBScript interoperability
|
|
| andrewwan1980 2007-06-16, 1:34 am |
|
How can VBScript code access JScript code variables in the same ASP
page?
<SCRIPT LANGAUGE="VBScript">
Dim a
a = 10
</SCRIPT>
<SCRIPT LANGUAGE="JScript">
Response.Write(a);
</SCRIPT>
Also, is this valid JScript code because ASP hasn't complained.
<SCRIPT LANGUAGE="JScript">
function Section(a, b, c, d) {
this.a = a;
this.memFunction = function() {
this.a = this.a + 1;
}
}
</SCRIPT>
Basically it's like JScript's way of declaring classes.
How can VBScript code create a Section object?
<SCRIPT LANGUAGE="VBScript">
Dim obj
obj = new Section 'Error, says cannot find Section
obj = new Section() 'Error again
obj = new Section(1, 2, 3, 4) 'Error again
</SCRIPT>
Also, is it possible to nest <SCRIPT> tag inside <% %>? Like:
<%
'Some VBScript code
Class AClass
Private a
Function b()
End Function
%>
<!-- #INCLUDE VIRTUAL="JScript.asp" -->
<%
End Class
%>
where JScript.asp has:
<SCRIPT LANGUAGE="JScript">
function Section() {
function Section2() {
}
}
</SCRIPT>
ASP didn't complain. But couldn't test whether the JScript functions
Section were member functions of the VBScript AClass.
--
andrewwan1980
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
| |
| Evertjan. 2007-06-16, 1:34 am |
| andrewwan1980 wrote on 15 jun 2007 in
microsoft.public.inetserver.asp.general:
[...]
>
> Also, is it possible to nest <SCRIPT> tag inside <% %>? Like:
>
> <%
> 'Some VBScript code
> Class AClass
> Private a
> Function b()
> End Function
> %>
> <!-- #INCLUDE VIRTUAL="JScript.asp" -->
> <%
> End Class
> %>
>
> where JScript.asp has:
>
> <SCRIPT LANGUAGE="JScript">
This clientside [= browser interpreted] script would only run in IE,
as FF and alike do not nknow of jscript.
Use:
<script type='text/javascript'> ...
> function Section() {
> function Section2() {
>}
>}
> </SCRIPT>
>
> ASP didn't complain.
ASP cannot complain, it is a language, the interpreter could,
but there is no sense to put cliendside scripting in a serverside class.
> But couldn't test whether the JScript functions
> Section were member functions of the VBScript AClass.
1 You are confusingly mixing serverside and clientside scripting.
2 There are NO asp pages, only asp files. asp files are interpreted on
the server, and mostly a resulting html page [be it most often still with
a .asp extension] is sent to the browser INCLUDING clientside scripting
as-is.
3 you can mix asp serverside(!) vbscript with asp serverside(!!!) jscript
by using the runat=server, example:
<% 'default vbscript assumed
response.write greetingz(3)
%>
<script language='jscript' runat='server'>
function greetingz(x){
if (x==3) return 'Hello World!';
return 'Get Lost!';
};
</script>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
|
|
|
|
|