469,904 Members | 2,413 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

can run javascript can't run vbscript - WHY

why does this work :-

<HEAD>
......
<SCRIPT LANGUAGE="javascript">
function test()
{
alert("test 1")
}
</SCRIPT>
.....
</HEAD>
<BODY>
....
<A HREF="javascript:test">test</A>
......
</BODY>

but this does not :-

<HEAD>
......
<SCRIPT LANGUAGE="vbscript">
function test()
msgbox("VB Test")
end function
</SCRIPT>
......
</HEAD>
......
<BODY>
....
<A HREF="vbscript:test">test</A>
....
</BODY>

As you can see the only real difference is I have changed JavaScript
to be vbscript and this is the problem. I don't even get a script
error reported by IE6 when I try to run the VB version. I tried
varying vbscript eg vb, vbs but nothing happens.

Why can I not run my vb function just like I can Javascript. It
defies logic (or at least mine!! which says a simple name change
should not cause this problem)

What I am trying to achieve is to run my actual code as a client side
script - with NO postback. I have managed to run some JavaScript
without causing a post back using the <A>...</A> and I can run my vb
actual code from a <ASP:BUTTON> but this causes a postback. I want
to use vb/vbscript as I am familiar with vb and want to get my pages
working asap.

One very frusttrated newbie (to ASP.NET / VB.NET)
Duncan
Nov 18 '05 #1
2 2339
The alert method is part of the document object model; it has nothing to do
with javascript. Try to use the alert method in your vbscript code block

<Script language="vbscript">
Function test()
alert("VB Test")
End Function
</Script>
"duncan" <dw***@woodace.co.uk> wrote in message
news:8f**************************@posting.google.c om...
why does this work :-

<HEAD>
.....
<SCRIPT LANGUAGE="javascript">
function test()
{
alert("test 1")
}
</SCRIPT>
....
</HEAD>
<BODY>
...
<A HREF="javascript:test">test</A>
.....
</BODY>

but this does not :-

<HEAD>
.....
<SCRIPT LANGUAGE="vbscript">
function test()
msgbox("VB Test")
end function
</SCRIPT>
.....
</HEAD>
.....
<BODY>
...
<A HREF="vbscript:test">test</A>
...
</BODY>

As you can see the only real difference is I have changed JavaScript
to be vbscript and this is the problem. I don't even get a script
error reported by IE6 when I try to run the VB version. I tried
varying vbscript eg vb, vbs but nothing happens.

Why can I not run my vb function just like I can Javascript. It
defies logic (or at least mine!! which says a simple name change
should not cause this problem)

What I am trying to achieve is to run my actual code as a client side
script - with NO postback. I have managed to run some JavaScript
without causing a post back using the <A>...</A> and I can run my vb
actual code from a <ASP:BUTTON> but this causes a postback. I want
to use vb/vbscript as I am familiar with vb and want to get my pages
working asap.

One very frusttrated newbie (to ASP.NET / VB.NET)
Duncan

Nov 18 '05 #2
abc
At http://telecom.fit.edu/cfdocs/htmlre...g_Scripts.html

you can find :

Scripting as a URL

As mentioned in the first paragraph, script events can also be included as URL's. For example :
<A HREF="javascript:alert('You can never have enough examples')">This is the link text</A>

NOTE : At the time of writing, only JavaScript was supported using this method. It works in both Netscape and Internet Explorer. Future versions of Internet Explorer will include support for a <A HREF="vbscript:...."> syntax.

However, Internet Explorer allows for cross-language referencing. You can use the above construct to call a scripting function, which can be a Visual Basic Script function. For example :
<A HREF="javascript:Exec_function()">This is the link text</A>

<SCRIPT LANGUAGE="VBScript">

<!--

Sub Exec_function

Alert "You executed a Visual Basic Script function called from a JavaScript reference"

End Sub

-->

</SCRIPT>

As you will see further in this scripting reference section, the anchor (<A>) element also supports various events using the above methods. This allows scripting to be combined with hypertext links, so that the link is not exclusively executing a script.

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ian Sedwell | last post: by
13 posts views Thread by Alex Molochnikov | last post: by
11 posts views Thread by Doug van Vianen | last post: by
9 posts views Thread by Erwin Moller | last post: by
5 posts views Thread by Tomislav | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.