Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to Call a Script from a Hyperlink

62 views
Skip to first unread message

D DiPalma

unread,
May 17, 2002, 2:05:53 PM5/17/02
to
I want to use a hyperlink instead of a button to do a VBScript that displays
a window. All the information I have found deals with a hyperlink calling a
file, but I want to run a script. How can I do that?

Thanks


Chris Barber

unread,
May 17, 2002, 2:16:19 PM5/17/02
to
Either use the onclick event and return a false value:

<a href="somepage.htm" onclick= "return somefunction();">Hyperlink</a>

or use the 'JavaScript' url method:

<a href="JavaScript: return somefunction();">Hyperlink</a>

<SCRIPT Language=JavaScript>
function somefunction(){
// do some stuff.
return false; // stops the hyperlink from being actioned.
}
</SCRIPT>

Pay attention to he return value - if you return 'true'; then the hypelink
will still fire and navigate to the href. If you return false then this
action will be cancelled.

Chris Barber.

"D DiPalma" <a@a> wrote in message news:#Hm#W1c$BHA.1540@tkmsftngp02...

Carmen de Lara

unread,
May 18, 2002, 2:46:59 PM5/18/02
to
This is an example, but there are 3 more forms to call a
vbscript from a hyperlink tag....

>.
>

ASP Page3.asp

Gary

unread,
May 21, 2002, 7:12:21 AM5/21/02
to
If we don't add the following code at the end of the script to be called,
the page will be directed to the new one specified by the"href" property of
the link:

window.event.returnValue=false

Her are the whole asp code:

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META name=VI60_defaultClientScript content=VBScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<SCRIPT LANGUAGE=vbscript>
<!--
sub link_onclick()
msgbox "You click me"
window.event.returnValue=false
end sub
-->
</SCRIPT>

</HEAD>
<BODY>

<P><A id="link" href="">Click Me</A></P>

</BODY>
</HTML>

Gary

This posting is provided "AS IS", with no warranties, and confers no
rights. Enjoyed ASP.NET? http://www.asp.net

0 new messages