Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 955403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:22:33+00:00 2026-05-16T00:22:33+00:00

I am writing an HTA and I need to pass a variable that I

  • 0

I am writing an HTA and I need to pass a variable that I have in Javascript to a VBScript function. Can you please let me know how to do this? Here is a (nonworking) example of what I’m trying to do:

<!DOCTYPE ... >
<html>
<head>    
    <HTA:APPLICATION ID="chrome" APPLICATIONNAME="kiosk" ... />
    ...
    <script type="text/javascript">
        ...
        var closer =  "C:\Program Files";
        ...
    </script>
    <script language="VBScript" src="close.vbs"></script>
</head>
<body>
<a href="#" onClick="VBScript:CloseExplorerWindow(window.closer)">close</a>
</body>
</html>

Please bear in mind that this example is waaaay oversimplified – I’ve just tried to strip out all the complexity and present you with what it is I’m actually trying to do.

Bonus: Is is possible to fire a VBScript function from a javascript one? My HTA uses jQuery quite extensively and it’d be nice to be able to do the system stuff I need to do from within jQuery.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:22:34+00:00Added an answer on May 16, 2026 at 12:22 am

    If a function is defined in VBScript, it can be executed from JavaScript as if it were any other globally available function. Both scripting languages share global variables and functions. I used to use a function so that I could access MsgBox from my JavaScript code using the following:

    <script type="text/vbscript">
    Function vbsMsgBox (prompt, buttons, title)
        vbsMsgBox = MsgBox(prompt, buttons, title)
    End Function
    </script>
    <script type="text/javascript">
    vbsMsgBox("This is a test", 16, "Test");
    </script>
    

    The order of inclusion is important when mixing these scripts. If the first script on your page is vbscript, that becomes the default scripting engine for event handlers. If the first is javascript, that would be the default. Providing vbscript: or javascript: is a common misconception – in JavaScript a string followed by a colon indicates a label commonly paired with loops and break/continue statements. In VBScript, it would just cause an error. This confusion stems with the method of running script from a URL, e.g. in the href of an <a> element:

    <a href="javascript:doSomething(); void(0);">do something</a>
    

    With your sample code, assuming closer is a global variable then your event handler should look like this:

    <a href="#" onclick="CloseExplorerWindow(closer)">close</a>
    

    Also, take a look at this MSDN article on using JScript and VBScript on the same page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using HTA and in it I have a function that should run a
Writing my first silverlight application. I need to deliver some bitmap that the customer
Writing a Jabber client that uses Twisted Words. I would like to know an
Writing a PHP app and have several classes that only have static methods (no
Writing a embeddable cross-browser plugin that is scriptable via JavaScript i am unsure how
I am writing an HTML Menu (StartMenu.hta). This menu runs from a DVD, but
Writing htaccess that allows me to remove index.php from the URL can confuse search
Writing a function I must declare input and output data types like this: int
Writing a stored procedure that will have multiple input parameters. The parameters may not
Writing a test app to emulate PIO lines, I have a very simple Python/Tk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.