I have an .hta file on a mapped drive that I can manually navigate to, double-click on the .hta file and it executes fine. However, I added a link to the full path on the share (from an IE 8 page) and when I try to run it from the link, as in:
Q:\path…\.hta
Then I get a javascript error an error occurred in running the script “length is null or not an object”. The javascript code is coming from the .hta file itself on this line:
...
for (var i = 0; i < matches.length; i++) {
...
I’m guessing that for some reason “i” isn’t initialized when the .hta is run off the link, rather than manually.
In any event, when I try to directly go to the file from the link, I do get a dialog asking if I want to run, save, or cancel the .hta file. When I try to run it, I get the javascript error.
So my questions are:
- how do I run this .hta file from a browser link?
- why do I get the javascript error when run from a link and not when it’s run manually?
HTA does not recognize mapped drives.
I assume you have your application saved at server, and then you run it at workstation, where you have this mapped driver
Qas a shortcut to the server.The correct path to server is something like this:
An actual IP can also be used instead of the
Your_Server_Name.To run the HTA in browser (IE only) without prompts, you’ll need to change many settings in Intranet zone security- and Advanced-tab to very insecure mode.
About the error message:
It seems, that
matcheshas not a property namedlength. Ifmatchesis defined, it’s probably a number or a boolean, or some other type of object which has not thelengthproperty.If the message is something like this:
Can't get the property length: object is null or not defined. This means, thatmatchesis undefined.Notice, that HTA is an independent application with it’s own
top.window, and it can’t interact with the browser window. (There is no way to refer theopenerin HTA, if the opener is a browser window.)